我写了以下PS脚本:
Get-ADUser -Filter * -SearchBase 'OU=Users & Computers, DC=aaaaaaa, DC=com' -Properties DisplayName | Export-CSV "ADUsers.csv"
据我所知,它应该只返回DisplayName。它返回了一切。问题是DistinguishedName稍后在我的进程中导致截断问题。如何让脚本只返回某些属性?
答案 0 :(得分:11)
使用select-object for expample:
Get-ADUser -Filter * -SearchBase 'OU=Users & Computers, DC=aaaaaaa, DC=com' -Properties DisplayName | select -expand displayname | Export-CSV "ADUsers.csv"
答案 1 :(得分:7)
这对我也很有用:
Get-ADUser -Filter * -SearchBase "ou=OU,dc=Domain,dc=com" -Properties Enabled, CanonicalName, Displayname, Givenname, Surname, EmployeeNumber, EmailAddress, Department, StreetAddress, Title | select Enabled, CanonicalName, Displayname, GivenName, Surname, EmployeeNumber, EmailAddress, Department, Title | Export-CSV "C:\output.csv"