Hi
we are trying to upgrade/install scom 2012 r2 agents to our windows servers (300+) server via powershell script.
we are wanting the result to be written to csv file but we are facing difficulty in trying to find the object/value to look at to the put the condition against.
we found the script that does for ping(below part script) result but we want to capture any failure. is there anything we can use to achieve what we ant to do?
Thank you in Advance.
-------------------Sample script--------------------------
# Ping the computer$pingStatus = Get-WmiObject -Class Win32_PingStatus -Filter "Address = '$computer'";
if($pingStatus.StatusCode -eq 0)
{
#If computer is up, write message and launch agent install
InstallSCOMAgent $Computer
"Success , $computer." | out-file "D:\output.csv" -Append -NoClobber
#Write-Host -ForegroundColor Green "Reply received from $computer.";
}
else
{
#Else, just write a message indicating computer unreachable
"Failed , $computer." | out-file "D:\output.csv" -Append -NoClobber
}
}