Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a script to get the website status is running or stopped from IIS manager.

But i coudln't get exact output.

Question: just i need to display website status is running or stopped in IIS using scripts.

$serverList = 'SSCCL35'

foreach ($server in $serverList) {

    $iis = Get-WmiObject Win32_Service -Filter "Name = 'sample'" -ComputerName $server

    if ($iis.State -eq 'Running') { Write-Host "IIS is running on $server" }
    Else { Write-Host "IIS is NOT running on $server" -ForegroundColor Red }

}


Note: "Sample" Service is running in my IIS. But i get output as "Not running".


Kindly help me out, Iam new to power-shell scripts.

What I have tried:

$serverList = 'QASCL35'

foreach ($server in $serverList) {

    $iis = Get-WmiObject Win32_Service -Filter "Name = 'sample'" -ComputerName $server

    if ($iis.State -eq 'Running') { Write-Host "IIS is running on $server" }
    Else { Write-Host "IIS is NOT running on $server" -ForegroundColor Red }

}
Posted
Updated 15-May-18 20:35pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900