How to change output of Invoke-WebRequest?
问题 I want to be able to get the results of Invoke-WebRequest and have my script print either "Failed" if the server was not reached or "Online" if it was reached. This is what I'm doing to try to do that. $IW_Results = $Servers_to_Check | ForEach-Object { Invoke-WebRequest -Uri $_ } $err = $IW_Results | ?{$_.gettype().Name -eq "ErrorRecord"} if($err){ Write-Output "Failed" } else { Write-Output "Online" } I was able to get the script to print "Online" if the server is reached. However when it