title: Access denied while running Windows Update using Powershell's Invoke-Command
body: <p>I've been trying to setup a Powershell module that would remotely call Windows/Microsoft update on a server using Invoke-Command, then process the updates, and send everything back to the calling server so it can send an email report.</p>
  
  <p>My issue comes when I try and call the downloader: Powershell seems to be requesting Elevated rights on the remote computer.</p>
  
  <p>Here is a snippet of what I'm trying to run and fail:</p>
  
  <pre><code>Invoke-Command -ComputerName $Server -Credential $Credentials -ScriptBlock {
      $UpdateSession = New-Object -ComObject "Microsoft.Update.Session"
      Write-Progress -Activity "Updating" -Status "Checking for new updates"
      $Criteria = "IsInstalled=0 and Type='Software'"
      $Updates = $UpdateSession.CreateUpdateSearcher().Search($Criteria).updates
      $Downloader = $UpdateSession.CreateUpdateDownloader()
      $Downloader.Updates = $Updates
  }
  </code></pre>
  
  <p>I know the issue isn't with remoting, as the first 4 commands work fine.
  The <code>$Credentials</code> variable points to pre-defined credentials, which are Local Admin on the remote server.</p>
  
  <p>When the script gets to the 5th line, <code>$Downloader = $UpdateSession.CreateUpdateDownloader()</code>, I get this error from Powershell:</p>
  
  <pre><code>Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
      + CategoryInfo          : OperationStopped: (:) [], UnauthorizedAccessException
      + FullyQualifiedErrorId : System.UnauthorizedAccessException
      + PSComputerName        : SERVER.sidlee.inc
  </code></pre>
  
  <p>What could be causing this exactly ?</p>
  
  <p>Thanks in advance for the help!</p>