开发者

Why this powershell code returns whole objects insted of just selected properties?

Why this powershell code returns whole objects insted of just selected properties ? I want to get only name and SID for each user not whole Microsoft.ActiveDirectory.Management.ADAccount object with bounch of properties开发者_JAVA百科.

PS C:\> Get-ADUser -filter * -SearchBase "OU=mailOnly,DC=test,DC=demo,DC=local" -server test.demo.local -properties SID,Name

Best regards, Primoz.


It appears that the -Property merely retrieves additional properties and tacks them onto the returned object e.g.:

Properties

Specifies the properties of the output object to retrieve from the server. Use this parameter to retrieve properties that are not included in the default set.

You can pick off the properties you want using Select-Object like so:

Get-ADUser -filter * -SearchBase "OU=mailOnly,DC=test,DC=demo,DC=local" `
           -server test.demo.local -properties SID,Name | Select SID,Name


The -properties option on Get-ADUser retrieves extended active directory properties beyond the base set included on the objects. If instead you want to see the value of those two properties, pass the result set through format-list.

Get-ADUser -filter * -SearchBase "OU=mailOnly,DC=test,DC=demo,DC=local" -server test.demo.local -properties SID,Name
 | format-list -property SID,Name
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜