Sometimes, IT admin want to know the web service is running or not. This script is to accomplish it.
$request = [Net.HttpWebRequest]::Create($SiteURL)
$request.Credentials = $Credentials
#Try to get the response from the specified site.If some errors occur, it means the service does not run or you don't have the Credential
try
{
#Get the response from the requst
$response = [Net.HttpWebResponse]$request.GetResponse()
Write-Host "The service is running."
$request.Abort()
}
Catch
{
Write-Warning "The service of site does not run or maybe you don't have the Credential"
}
$request = [Net.HttpWebRequest]::Create($SiteURL) $request.Credentials = $Credentials#Try to get the response from the specified site.If some errors occur, it means the service does not run or you don't have the Credentialtry { #Get the response from the requst$response = [Net.HttpWebResponse]$request.GetResponse() Write-Host "The service is running."$request.Abort() } Catch { Write-Warning"The service of site does not run or maybe you don't have the Credential" }



