Solved

Pull attributes from multiple machines with powershell

Posted on 2014-07-17
3
1,086 Views
Last Modified: 2014-07-22
Hi EE

I am needing to pull the attributes below from multiple machines .. The line below pulls it but I am also receiving an error .

gc servers.txt | Get-ADComputer -Properties * | Select Name,OperatingSystem,OperatingSystemServicePack,LastLogonDate,CanonicalName | Export-Csv sample.csv -nti

This is the error I am receiving .. any ideas ?

Get-ADComputer : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and
its properties do not match any of the parameters that take pipeline input.
At line:1 char:18
+ gc servers.txt | Get-ADComputer -Properties * | Select Name,OperatingSystem,Oper ...
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:PSObject) [Get-ADComputer], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADComputer
0
Comment
Question by:MilesLogan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 300 total points
ID: 40204588
Do you have any empty lines in servers.txt?

What if you try the following code?
GC servers.txt | ?{$_}|Get-ADComputer -Properties * | Select Name,OperatingSystem,OperatingSystemServicePack,LastLogonDate,CanonicalName | Export-Csv sample.csv -nti

Open in new window

0
 
LVL 25

Assisted Solution

by:Coralon
Coralon earned 200 total points
ID: 40205835
You probably need to wrap it in a foreach loop..

get-content -path .\servers.txt | foreach-object { Get-ADComputer -Properties * -identity $_ | Select-Object -Property Name,OperatingSystem,OperatingSystemServicePack,LastLogonDate,CanonicalName } | Export-Csv -filepath .\sample.csv -notypeinformation

Open in new window


I removed the shortcuts/aliases, and used the full path names for other people.. (it makes it easier to read).

Coralon
0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 40211599
Thank you both !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A hard and fast method for reducing Active Directory Administrators members.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question