PowerShell to get system information from remote computers

Updated on 16th January 2017

This is a very useful PowerShell script for system administrators / network administrators to automatically create an inventory list of devices. This script reads a list of computer names or IP addresses from a CSV file and remotely gets the system information such as System name, Operating system details, disk capacity details, network information etc., The output is printed on the screen and also written into a CSV file.

To run the script you need to pass two parameters - an input csv file and an output csv file with full path. See example below:

PS C:\> Get-SysInfo c:\IPaddressList.csv c:\SysInfo.csv

The input csv file must contain a column with header ComputerName that contains the list of host names or IP addresses. Column header name is set in the variable $ColumnHeader. For each of the computers in the list, the script will get instances of Windows Management Instrumentation (WMI) classes using the Get-WmiObject PowerShell cmdlet. The information that we want collect comes from three WMI classes - Win32_OperatingSystem, Win32_Volume and Win32_NetworkAdapterConfiguration. The collected information is stored in a Hash table which is basically a collection of name value pairs. We then create a PowerShell object with name in Hash table as Property Name and the value in hash table as Property Value. Finally the new PowerShell object is output to CSV file using Export-CSV cmdlet.


  Powershell script to get system information from remote computers.
  This PowerShell script reads a list of computer names (or IP Addresses)
  from a CSV file and remotely gets the system information related to its
  Operating System, Disk and network. The output is written to a another
  CSV file in table format. 
   File name and path of the input CSV file to read.

   File name and path of the outout CSV file.
  Version:        1.0
  Author:         Open Tech Guides
  Creation Date:  16-Jan-2017
  Get-SysInfo c:\IPaddressList.csv c:\SysInfo.csv

  [Parameter(Mandatory=$true, position=0)][string]$infile,
  [Parameter(Mandatory=$true, position=1)][string]$outfile

#Column header in input CSV file that contains the host name 
$ColumnHeader = "ComputerName"
$HostList = import-csv $infile | select-object $ColumnHeader
$out = @()

foreach($object in $HostList) {
    $os = Get-WmiObject -computername $object.("ComputerName") -class win32_operatingsystem
    $vol = Get-WmiObject -computername $object.("ComputerName") -class Win32_Volume
    $net = Get-WmiObject -computername $object.("ComputerName") -class Win32_NetworkAdapterConfiguration | where-object { $_.IPAddress -ne $null }

    $DeviceInfo= @{}
    $DeviceInfo.add("Operating System", $os.name.split("|")[0])
    $DeviceInfo.add("Version", $os.Version)
    $DeviceInfo.add("Architecture", $os.OSArchitecture)
    $DeviceInfo.add("Serial Number", $os.SerialNumber)
    $DeviceInfo.add("Organization", $os.Organization)
    $DeviceInfo.add("Disk Capacity", "$([math]::floor($vol.Capacity/ (1024 * 1024 * 1024 )) )" + " GB" )
    $DeviceInfo.add("Free Capacity", "$([math]::floor($vol.FreeSpace/ (1024 * 1024 * 1024 )))" + " GB" )
    $DeviceInfo.add("System Name", $vol.SystemName)
    $DeviceInfo.add("File System", $vol.FileSystem)
    $DeviceInfo.add("IP Address", ($net.IPAddress -join (", ")))
    $DeviceInfo.add("Subnet", ($net.IPSubnet  -join (", ")))
    $DeviceInfo.add("MAC Address", $net.MACAddress )

    $out += New-Object PSObject -Property $DeviceInfo | Select-Object `
              "System Name", "Organization", "Serial Number","Operating System", `
              "Version","Architecture","File System","Disk Capacity", `
              "Free Capacity","MAC Address","IP Address","Subnet"

    Write-Verbose ($out | Out-String) -Verbose             
    $out | Export-CSV $outfile -NoTypeInformation

Here is a sample input file IPAddressList.csv containing IP addresses and host names. Note the column header is "ComputerName". If you want to use a different column header then change the $ColumnHeader variable accoringly.

IP Address list

Below is the output file that script generates.

System Info

If the output CSV file that you pass as argument already exists, then it will be overwritten. If the file doesn't exist then it will be created.

Post a comment


Your Comment

Email (We dont publish it)


Nothing yet..be the first to share wisdom.