Power shell script to get Computer Description + OU details

I do not get any output when I try

PS C:\Windows\System32> Get-ADComputer -Computername "ABCD1DT001"  

I need to be able to get "Computer Object Description" and "distinguished name (OU)" of 100 remote machines.

closed as off-topic by Ward, mdpc, fukawi2, Reaces, Wesley Nov 29 '15 at 7:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • I posted an answer below, but you should have done some research on the commandlet first to try and figure out why you were receiving the error, and if you did do that you should have stated what steps you took in trying to resolve your issue. – bentek Nov 18 '15 at 18:13

First, -computername is not a valid parameter for the Get-ADComputer commandlet.

You want to use the -identity parameter instead.

Get-ADComputer -identity "ABCD1DT001"

Now in order to retrieve the Description value, you will have to specify that property in your command, since it is not one of the properties which are retrieved by default. The Name and DistinguishedName properties are retrieved by default for this commandlet.

Get-ADComputer -Identity "ABCD1DT001" -Properties Description | ft -a Name,DistinguishedName,Description

Lastly, to run this for your 100 machines, you can create a loop against the list of machines and then display the results in the format you choose.

$results = get-content c:\textfilewithcomputernames.txt | % { Get-ADComputer -Identity $_ -Properties Description }
$results | ft -a Name,DistinguishedName,Description

Not the answer you're looking for? Browse other questions tagged or ask your own question.