Retrieve users and export to CSV from a managed unit with powershell

as title, for an OU i would just use a simple script block like this - 

$OUpath = 'ou=Managers,dc=enterprise,dc=com'
$ExportPath = 'c:\data\users_in_ou1.csv'
Get-ADUser -Filter * -SearchBase $OUpath | Select-object
DistinguishedName,Name,UserPrincipalName | Export-Csv -NoType $ExportPath

but with a managed unit, the commands dont line up. ive used Get-QAD user and -proxy but fails. 

any tried and tested code for a simple export?

Top Replies

  • Hi  

    $ManagedUnitDN = "CN=SSIM,CN=_HowTo,CN=Managed Units,CN=Configuration"
    $ExportPath = "$($env:USERPROFILE)\Desktop\Users_in_MU_$(get-date -Format "ddMMyyHHmmss").csv"
    $LDAPFilter = "(objectClass…

Parents
  • Hi  

    $ManagedUnitDN = "CN=SSIM,CN=_HowTo,CN=Managed Units,CN=Configuration"
    $ExportPath = "$($env:USERPROFILE)\Desktop\Users_in_MU_$(get-date -Format "ddMMyyHHmmss").csv"
    $LDAPFilter = "(objectClass=user)"
    
    Get-QADUser -SearchRoot $ManagedUnitDN -LdapFilter $LDAPFilter -SizeLimit 0 -Proxy | Select-Object DN,Name,UserPrincipalName | Export-Csv -NoTypeInformation -Path $ExportPath

Reply
  • Hi  

    $ManagedUnitDN = "CN=SSIM,CN=_HowTo,CN=Managed Units,CN=Configuration"
    $ExportPath = "$($env:USERPROFILE)\Desktop\Users_in_MU_$(get-date -Format "ddMMyyHHmmss").csv"
    $LDAPFilter = "(objectClass=user)"
    
    Get-QADUser -SearchRoot $ManagedUnitDN -LdapFilter $LDAPFilter -SizeLimit 0 -Proxy | Select-Object DN,Name,UserPrincipalName | Export-Csv -NoTypeInformation -Path $ExportPath

Children
No Data