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

Reaces
  • 5,597
  • 4
  • 38
  • 46
Cranta Ionut
  • 179
  • 3
  • 4
  • 12

1 Answers1

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
Johan de Haan
  • 391
  • 2
  • 7