need help to list users with second owner in a csv file

Hello.

My Problem is, i have to list all Users in a specified OU, with entries in the Second Owner field.

How i can do this and export in a CSV File?

Would be great if someone could help.

Thanks and best regard

Eddi

Parents
  • If you show us your script, we can suggest how to update it to get by the issue.  Mostly likely you will need to do an '-ExpandProperty' on edsvaSecondaryOwners but we need to see your existing code in order to suggest the appropriate modifications.

  • Hi. 

    Sorry, here is my script. 

    Connect-QADService -Proxy -Credential (Get-Credential)
    Get-QADUser -Sizelimit 0 -searchroot 'OU=example_Accounts_Users_external,OU=Accounts_Users_external,OU=external,OU=Users,OU=Accounts,DC=corp,DC=example,DC=com' -IncludedProperties edsvaSecondaryOwners | Select-Object -Property Name,edsvaSecondaryOwners | Export-CSV -Path c:\temp\UserExport2.csv

    This is my output:

    #TYPE Selected.ActiveRoles.ManagementShell.Data.ArsUserObject
    Name,"edsvasecondaryowners"
    EXT Lukas,"CN=Matthias,OU=Accounts_Users_internal,OU=Accounts_Users_internal,OU=internal,OU=Users,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Leonhard,"CN=Matthias,OU=Accounts_Users_internal,OU=Accounts_Users_internal,OU=internal,OU=Users,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Richard,"CN=Matthias,OU=Accounts_Users_internal,OU=Accounts_Users_internal,OU=internal,OU=Users,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Klaus,"CN=Matthias,OU=Accounts_Users_internal,OU=Accounts_Users_internal,OU=internal,OU=Users,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Marian,"CN=Florian - Depro 2020-01-22,OU=Accounts_Disabled,OU=_Disabled,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Dmytro,"CN=Florian - Depro 2020-01-22,OU=Accounts_Disabled,OU=_Disabled,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Robert,"System.Object[]"
    EXT Scrum,"System.Object[]"
    EXT BASE,"CN=Juergen,OU=Accounts_Users_internal,OU=Accounts_Users_internal,OU=internal,OU=Users,OU=Accounts,DC=corp,DC=example,DC=com"
    EXT Eva,"System.Object[]"
    EXT Gabriel,"System.Object[]"
    EXT Johannes,"System.Object[]"

    Thanks and BR

    Eduard

  • Quick fixes to your select and export CSV:

    Select-Object -Property Name,@{Name="edsvaSecondaryOwners";Expression={[string]::join(";",($_.edsvaSecondaryOwners))}} | Export-CSV -Path c:\temp\UserExport2.csv -NoTypeInformation

    NOTES

    1.  The Name / Expression allows you to take a returned property and do some transformation on it (described below)

    2.  The string/join takes the ...SecondaryOwners list and converts it to a string delimited by semi-colons.

    Reference

    3.  The "-notypeinformation" gets rid of the message at the top of your output file.

  • Had to edit the above...please re-check online version

  • Hi Johnny

    Thanks for your help! 

    It works for me Smiley  

    Thanks a lot, you saved my day. 

    Cheers Eduard

Reply Children
No Data