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