Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pull attributes from multiple machines with powershell

Posted on 2014-07-17
3
Medium Priority
?
1,121 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 1200 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 800 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

Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

Question has a verified solution.

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

Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

886 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