Solved

Pull attributes from multiple machines with powershell

Posted on 2014-07-17
3
999 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
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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