title: How to get all (IIS) websites status/state from remote machine using PowerShell?
body: <p>I was trying to read the status of IIS website from remotely. I tried below code.</p>
  
  <pre><code>$Session = New-PSSession -ComputerName $serverName
  $block = { 
  import-module 'webAdministration'
  Get-ChildItem -path IIS:\Sites
  }
  Invoke-Command -Session $Session -ScriptBlock $block  | Out-File -append $WebreportPath
  </code></pre>
  
  <p>But above command given me only Websites with https binding, when it comes to https it throws below error.</p>
  
  <pre><code>The data is invalid. (Exception from HRESULT: 0x8007000D)
  + CategoryInfo          : NotSpecified: (:) [Get-ChildItem], COMException
  + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.GetChildItemCommand
  </code></pre>
  
  <p>I am trying to renmote a Windows Server 2008 R2 with IIS 7.
  Please guide me. Thanks !</p>