Use Powershell to check Website Connectivity

We have some issues that some systems cannot reach our MECM server, and that was due to the new network changes. I wrote this script to find out which machines cannot reach our MECM server.

Here is the code:

# SCCM Server Network Connectivity Test
# Rui Qiu
# v1.0
# 1/16/2022

#$Result = Test-NetConnection -ComputerName ServerName
Invoke-WebRequest https://sccmserver_address/SMS_MP -DisableKeepAlive -UseBasicParsing -Method head -ErrorAction Stop
$Result = $Error[0] | Out-String
if($Result.Contains("(401) Unauthorized"))
{$Compliance = “Yes”}
{$Compliance = “No”}


To check which type of errors you have, you can try $Error[0] | Get-Member and then find the exact item you want to check.

Leave a Comment