Solved

Pull attributes from multiple machines with powershell

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

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

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now