PowerShell

PowerShell: Documenting your environment by running systeminfo on all Domain-Computers

Systeminfo gives you a perfect overview of your system. But what about the other systems in your domain? Sure, you can use 3rd Party Tools or SCCM. But the number of those who can´t use enterprise software is greater than you think. In this article I am going to describe how to run systeminfo on all Client Computer without using 3rd Party Tools.

What is systeminfo?

Open PowerShell. Type systeminfo.

systeminfo

Unbenannt.PNG

Next, the goal is to get that useful information for all Domain Computers.

Running systeminfo on all Domain Computers

Log on to the domain as a Member of the Domain Admins Group. Run the following command:

(Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV}} | ConvertFrom-Csv | Out-GridView

Unbenannt.PNG

This will give you a perfect overview of your environment. But we are faced with two problems. Those red one’s are not good one’s 😉

Problem 1

If you get an error, then one of your workstations or servers isn´t responding. The reason can be manifold. The computer might be switched off.

Unbenannt1.PNG

To avoid this, run Foreach-Object with the parameter -ErrorAction SilentlyContinue.

(Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV} -ErrorAction SilentlyContinue} | ConvertFrom-Csv | Out-GridView

Problem 2

Now let´s solve the next problem. Let´s remove the annoying Header Lines. We want only one header for all computers.

Unbenannt3.PNG

To remove the multiple headers run

(Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV} -ErrorAction SilentlyContinue | Select-Object -Skip 1} | ConvertFrom-Csv -Header "Host Name","OS","Version","Manufacturer","Configuration","Build Type","Registered Owner","Registered Organization","Product ID","Install Date","Boot Time","System Manufacturer","Model","Type","Processor","Bios","Windows Directory","System Directory","Boot Device","Language","Keyboard","Time Zone","Total Physical Memory","Available Physical Memory","Virtual Memory","Virtual Memory Available","Virtual Memory in Use","Page File","Domain","Logon Server","Hotfix","Network Card","Hyper-V" | Out-GridView

Unbenannt.PNG

Perfect. 😉

Have fun documenting your systems.

See also

PowerShell: Force gpupdate on all Domain Computers

Restart all Domain Computers by using PowerShell

PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk)

13 replies »

  1. The script is good but it does not fetch all the computers present in my domain which are active and logged in by users in the grid view , Patrick any idea . I also tried your Get-SystemInfo function, even it does not fetch all the computers details .May be others are facing the same. Your help is appreciated.

    Like

      • Hi,
        Thanks for your reply, i checked the machines which are not comming in the list ,remote Management service is running and firewall is off but still those computers doesnt list up, is there a way to pass those computers names from your script and check.

        Like

  2. Is this supposed to work on Server 2008r2? Am I doing something wrong? Please let me know if you need more info.

    PS C:\Users\tempadmin> (Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV}} | ConvertFrom-Csv | Out-GridView

    ***Error***
    Invoke-Command : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
    At line:1 char:79
    + (Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName <<<< $_ {systeminfo /FO CSV}} | ConvertFrom-Csv | Out-GridView
    + CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand

    Like

  3. Good Work. This is what i was looking for , It will add more value if you could add “Individual Computers” in scope and it will have comma separated computer names so that user can specify the choice of his own computers. The other most information missing here is about the Hard Disk info about computers. Also one suggestion if you rewrite this using these commandlets (Get-WmiObject or Get-CimInstance ) it will be much fast in bringing results.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.