Monday, June 9, 2014

IIS version and status check - Powershell

Below is the script to check IIS version and its status.

1. Copy below script and save it as .ps1

$servers = (Get-Content servers.txt)

foreach($vm in $servers){
$IISversion = get-itemproperty HKLM:\SOFTWARE\Microsoft\InetStp\  | select versionstring 
$iis = get-wmiobject Win32_Service -ComputerName $vm -Filter "name='IISADMIN'"

if($iis.State -eq "Running")
{Write-Host "IIS is running on $vm" and Version is $IISversion}

else
{Write-Host "IIS is not running on $vm"}
}

2. Populate server name in servers.txt

3. Execute the script.