14

我编写了以下 PS 脚本:

Get-ADUser -Filter * -SearchBase 'OU=Users & Computers, DC=aaaaaaa, DC=com' -Properties DisplayName | Export-CSV "ADUsers.csv"

据我所知,它应该只返回 DisplayName。它正在返回一切。问题是 DistinguishedName 稍后在我的过程中导致截断问题。如何让脚本只返回某些属性?

4

2 回答 2

13

使用select-object例如:

Get-ADUser -Filter * -SearchBase 'OU=Users & Computers, DC=aaaaaaa, DC=com' -Properties DisplayName | select -expand displayname | Export-CSV "ADUsers.csv" 
于 2013-05-14T13:56:05.363 回答
8

这也对我有用:

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"
于 2014-02-06T00:02:01.863 回答