Hi Guys,
I am trying to create a function which will check for a specific KB on a list of servers and generate the report, I am all done so far, however can someone help me on a validation for checking the servers status, What I am looking for is if the server is online then only the script would run else the it will write an error in the report file. I have tried using test-connection but dunno about array and collection as I am not from a developing back ground.
Below is what I have wrote so far.
function Get-PatchDetails
{
[CmdletBinding()]
Param (
$path,
$id,
$reportfile)
$Computers=Get-Content -Path $path
foreach ($c in $Computers)
{
if (Get-HotFix -Id $id -ComputerName $c )
{Add-Content “$c have the patch $id” -Path $reportfile}
else
{(Add-Content “$c doesnt have the patch $id” -Path $reportfile)}
}
}