title: Install windows updates remotely
body: <p>I have a power shell script to download and install windows updates on Windows server 2012 R2. The script is working fine when i login to the remote machine and execute the script. The script fails when i try tio install it via powershell using invoke command. When i use invoke command the script downloads the files without any issue but it never installs the files. Below is the script i have</p>
  
  <pre><code>$MSUs = @('https://download.microsoft.com/download/D/6/0/D60ED3E0-93A5-4505-8F6A-8D0A5DA16C8A/Windows8.1-KB2919442-x64.msu',
  'https://download.microsoft.com/download/2/5/6/256CCCFB-5341-4A8D-A277-8A81B21A1E35/Windows8.1-KB2919355-x64.msu',
  'https://download.microsoft.com/download/2/5/6/256CCCFB-5341-4A8D-A277-8A81B21A1E35/Windows8.1-KB2932046-x64.msu',
  'https://download.microsoft.com/download/2/5/6/256CCCFB-5341-4A8D-A277-8A81B21A1E35/Windows8.1-KB2934018-x64.msu',
  'https://download.microsoft.com/download/2/5/6/256CCCFB-5341-4A8D-A277-8A81B21A1E35/Windows8.1-KB2938439-x64.msu'
  )
  
  foreach ($MSU in $MSUs) {
  $FileName = "C:\Temp\$(Split-Path $MSU -Leaf)"
  Write-Host "Downloading package: $(Split-Path $MSU -Leaf)"
  (New-Object System.Net.WebClient).DownloadFile($MSU, $FileName)
  Write-Host "Installing package: $(Split-Path $MSU -Leaf)"
  Start-Process wusa -ArgumentList "$FileName /quiet /norestart" -Wait
  }
  </code></pre>
  
  <p>I try to execute the script with below command</p>
  
  <pre><code>Invoke-Command -Credential $cred -ComputerName 10.xx.xx.xxx -ScriptBlock { C:\\Temp\\1_KB.ps1| write-host}
  </code></pre>