title: Check whether IIS is installed or not
body: <p>I am writing a PowerShell script to host a website in IIS.</p>
  
  <p>I tried this script in a machine where there is no IIS installed and I got error so I want to check if IIS is installed and then I want to host a website in ISS.</p>
  
  <p>Below is the script I am trying but it is not working:</p>
  
  <pre><code>$vm = "localhost";
  $iis = Get-WmiObject Win32_Service -ComputerName $vm -Filter "name='IISADMIN'"
  
  if ($iis.State -eq "Running") {
      Write-Host "IIS is running on $vm"
  } 
  else {
      Write-Host "IIS is not running on $vm"
  }
  </code></pre>
  
  <p>Please help me with any PowerShell script to check if IIS is installed or not.</p>