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