0

Get-ADUser -SearchBase "dc=contoso,dc=local" -filter * -properties Name, Surname, samAccountName, Enabled, PasswordNeverExpires, PasswordExpired, PasswordLastSet, MemberOf | Select Name, Surname, SamAccountName, Enabled, PasswordExpired, MemberOf | Export-Csv C:\temp\expired3.csv

I need a list of all users in the domain with this respective attributes, the problem is with the MemberOf attribute. Instead of getting the groups that they are part of I only get Microsoft.ActiveDirectory.Management.ADPropertyValueCollection

3

You can use Select @{name=”MemberOf”;expression={$_.memberof -join “;”}} to export the multivalued attribute "MemberOf" to your CSV:

Get-ADUser -SearchBase "dc=contoso,dc=local" -filter * -properties Name, Surname, samAccountName, Enabled, PasswordNeverExpires, PasswordExpired, PasswordLastSet, MemberOf | `
        Select Name, Surname, SamAccountName, Enabled, PasswordExpired, @{name=”MemberOf”;expression={$_.memberof -join “;”}} | `
            Export-Csv C:\temp\expired3.csv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.