3

When I run Get-ADComputer cmdlet, I can view all of the single object's properties, like below.

C:\PS>Get-ADComputer "Fabrikam-SRV1" -Properties *


AccountExpirationDate              :
accountExpires                     : 9223372036854775807
AccountLockoutTime                 :
AccountNotDelegated                : False
AllowReversiblePasswordEncryption  : False
BadLogonCount                      :
CannotChangePassword               : False
CanonicalName                      : Fabrikam.com/Computers/fabrikam-srv1

I then can filter which Properties to display in the output. Is this possible to get all of the Properties for a list of computer objects in a file (txt or csv) and then filter the needed one?

Something like this Get-ADComputer -Computer (Get-Content -Path .\computers.txt) | Select CanonicalName,CN,DistinguishedName

1 Answer 1

4

Is this possible to get all of the Properties for a list of computer objects in a file (txt or csv) and then filter the needed one?

Yes. Assuming the file computers.txt contains only a single computer name per-line.

Get-Content computers.txt |
  Get-ADComputer -Properties * |
    Select-Object CanonicalName, CN, DistinguishedName

Moreover, you can skip the -Properties * (could be slow if dealing with many computers) and just choose which properties to retrieve in addition to the default ones. The DistinguishedName is included in the default set.

Get-ADComputer -Properties CanonicalName, CN

If you've a CSV, you'll need to determine which column or heading name contains the computer name. If you provide an example formatted CSV, I'll update my answer.

1
  • Assuming the file computers.txt contains only a single computer name per-line, - that's totally correct assumption. Thanks! Oct 6, 2015 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .