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
我需要具有相应属性的域中所有用户的列表,问题出在属性上MemberOf
。我没有得到他们所属的组,而是只得到了Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
答案1
您可以使用Select @{name=”MemberOf”;expression={$_.memberof -join “;”}}
将多值属性“MemberOf”导出到 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