Saturday, 16 November 2013

PowerShell Script to pull Computer names and Serial numbers remotely.

PowerShell Script to pull Computer names and Serial numbers remotely.

Put computer Names or IP Address in a text file to which we need serial numbers.

Like I did in my case C:\sss.txt is a file which needs to have Computer names or Serial Numbers.


$colComputers = Get-Content C:\sss.txt
$ErrorActionPreference = "SilentlyContinue"
foreach ($StrComputer in $colComputers)
{
$GenItems1 = gwmi Win32_ComputerSystem -Comp $StrComputer
$sn = Get-WmiObject -Class win32_bios -Comp $StrComputer
if(!$GenItems1){
$a = Write-Host “$StrComputer not found”
}
else
{
$a = Write-Host $StrComputer, $sn.SerialNumber
}
}

$props = @{          
   Table =  $a
   
    
    }
New-Object PSObject -Property $props | Ft -Autosize

No comments:

Post a Comment

Install Multiple Software with a Click