title: Recycling IIS application pool using PowerShell: "Exception calling Recycle"
body: <p>It looks like a recent windows update has broken some functionality I was using to recycle IIS6 application pools, as this has been working for months up to today.</p>
  
  <pre><code>Exception calling "Recycle" : "Win32: The object identifier does not representException calling "Recycle" : "Win32: The object identifier does not represent a valid object.
  </code></pre>
  
  <p>the function I was using to recycle the application pools was:</p>
  
  <pre><code>function recycle-pool($strServerName)
  {
      $objWMI = [WmiSearcher] "Select * From IIsApplicationPool"
      $objWMI.Scope.Path = "\\" + $strServerName + "\root\microsoftiisv2"
      $objWMI.Scope.Options.Authentication = 6
      $pools = $objWMI.Get()
      foreach ($pool in $pools)
      {
          $pool.recycle()
          if (!$?)
          {
              Write-Host $pool.name " - ERROR"
          }
          else
          {
              Write-Host $pool.name " - Recycled"
          }
  }
  </code></pre>
  
  <p>Any idea on what the problem is and how I should approach this?</p>