1

I'm attempting to push a windows hotfix to a number of computers on our network, using PowerShell v3. I've downloaded the appropriate .msu file, I've been able to successfully install it from the local machine on the command line, using:

wusa c:\temp\hotfixname.msu /quiet /norestart

The problem comes when I try to run it from powershell. We can assume that the msu is already on everyone's machine, at c:\temp\hotfixname.msu, and that PSRemoting is already enabled. Here's what I have more or less:

import-module ActiveDirectory

$AllPCs = Get-ADComputer -SearchBase "Appropriate OU Here" -filter *

$AllPCs | Foreach {
Invoke-Command -ComputerName "$($_.name)" -AsJob -ScriptBlock { 
        if (!(Get-HotFix -id hotfixkb)) { CMD /C "wusa.exe c:\temp\hotfixname.msu /quiet /norestart" }
    }
 }

When run like this from my own admin box, running powershell as admin, the local machine opens a wusa.exe process for a second or so, before it disappears. Nothing is installed.

I can run CMD /C "wusa.exe /?, and it does open the process (it hangs, but only because wusa opens its help in a GUI).

I'm out of ideas - does anyone have any advice on this? Is there something I'm missing?

2 Answers 2

3

Since PSRemoting uses WinRM and according to this it doesn't look like you can use wusa.exe with WinRM or WinRS it doesn't look possible with the code you listed.

There is a workaround listed however:

Extract the .msu file through Windows Remote Shell with WUSA using the following command:

winrs.exe -r:%computername% wusa.exe %kb-update% /extract:%destination%

When complete, install the .cab package with dism.exe or Package Manager. To use dism.exe, use the command below:

winrs.exe -r:%computername% dism.exe /online /add-package /PackagePath:%Path_To_Package%\KBnnnnnnn.cab

3
  • 3
    We wound up running a scheduled task to force the local PC to run wusa.exe, which seemed to do the trick!
    – bjscollura
    Commented Mar 27, 2015 at 22:00
  • On my copy of Win 10 v1607 and v1903, I get "The /extract option is no longer supported" when I try to run wusa.exe this way Commented Aug 20, 2020 at 7:27
  • 1
    @Hydrargyrum Try using expand -f:* myupdate.msu c:\myexpandloc
    – Josh
    Commented Aug 20, 2020 at 22:11
0

remote update of powershell from 3 -> 5.1 (windows7), through the WinRM interface and Ansible server - PSH update-psh.ps1 script (worked for me):

# install POWERSHELL update
# descr. wusa: https://support.microsoft.com/en-us/help/934307/description-of-the-windows-update-standalone-installer-in-windows
# descr. dism: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism-operating-system-package-servicing-command-line-options 

Start-Process -FilePath 'wusa.exe' -ArgumentList "C:\workit\updatePSH\Win7AndW2K8R2-KB3191566-x64.msu /extract:C:\workit\updatePSH" -Verb RunAs  -Wait -Passthru

Start-Sleep -Seconds 5

Start-Process -FilePath 'dism.exe' -ArgumentList "/online /add-package /PackagePath:C:\workit\updatePSH\WSUSSCAN.cab /PackagePath:C:\workit\updatePSH\Windows6.1-KB2809215-x64.cab /PackagePath:C:\workit\updatePSH\Windows6.1-KB2872035-x64.cab /PackagePath:C:\workit\updatePSH\Windows6.1-KB2872047-x64.cab /PackagePath:C:\workit\updatePSH\Windows6.1-KB3033929-x64.cab /PackagePath:C:\workit\updatePSH\Windows6.1-KB3191566-x64.cab /IgnoreCheck /quiet" -Verb RunAs -Wait -PassThru
1
  • 1
    please fix the formatting of your answer (no need for 'code' tag, just indent relevant lines with 4 spaces ...) Commented Dec 1, 2017 at 13:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .