Solved

Pull attributes from multiple machines with powershell

Posted on 2014-07-17
3
1,055 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

739 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