Wednesday, May 2, 2012

Bulk processing for querying servers from text file

This script extends the first script and simply gets the hostname, operating system and service pack level for each server listed in the input file. Save below script code as a .ps1 file then call it passing the file name containing the list of computer names.


$filename = $Args[0]
$TheFile = Get-Content $filename
foreach ($Line in $TheFile)
{
Get-WmiObject Win32_OperatingSystem -computername $Line | format-table CSName, caption, CSDVersion -autosize
}

No comments: