My apologies I forgot to mention that you must have CredSSP enabled in your environment in order to access a network share from a remote machine. This involves running Enable-WSManCredSSP on the remote machines as well as your machine. I set CredSSP via group policy in my environment. All the same, you have to add “-Authentication CredSSP” as well as a credential to the Invoke-Command cmdlet for it to work.
There also seems to be an issue with executing wusa.exe on remote machines. HERE
That last KB offers a helpful suggestion though, to extract the contents of the msu and install the cab via DISM. I’ve tested the following and it does work.
$creds=Get-Credential
$cmd={
Switch ($env:PROCESSOR_ARCHITECTURE){
"AMD64" {
Start-Process wusa.exe -ArgumentList '"\\server\share\Windows6.1-KB2819745-x64-MultiPkg.msu" /extract:C:\MSU\' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2809215-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872035-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872047-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2819745-x64.cab /NoRestart' -Wait
Remove-Item C:\MSU -Recurse -Force
Restart-Computer -Force
}
"x86" {
Start-Process wusa.exe -ArgumentList '"\\server\share\Windows6.1-KB2819745-x86-MultiPkg.msu" /extract:C:\MSU\' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872035-x86.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872047-x86.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2819745-x86.cab /NoRestart' -Wait
Remove-Item C:\MSU -Recurse -Force
Restart-Computer -Force
}
}
}
Invoke-Command -ComputerName $(Get-Content "F:\WindowsManagementFramework4.0\Computer Lists\test list.txt") -ScriptBlock $cmd -Authentication Credssp -Credential $creds
I suppose the only thing you will have to tackle is either enable CredSSP on your machines, or put the install packages local on the machines.
To incorporate your method of copying the package over, you could do something like this, and it would not require CredSSP:
$HotFix_32bit = "F:\WindowsManagementFramework4.0\Update\Windows6.1-KB2819745-x86-MultiPkg.msu"
$HotFix_64bit = "F:\WindowsManagementFramework4.0\Update\Windows6.1-KB2819745-x64-MultiPkg.msu"
ForEach($computer in $(Get-Content "F:\WindowsManagementFramework4.0\Computer Lists\test list.txt")){
If($(Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit"){
Copy-Item $HotFix_64bit "\\$computer\c$" -Force
$cmd={
Start-Process wusa.exe -ArgumentList '"C:\Windows6.1-KB2819745-x64-MultiPkg.msu" /extract:C:\MSU\' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2809215-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872035-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872047-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2819745-x64.cab /NoRestart' -Wait
Remove-Item C:\MSU -Recurse -Force
Restart-Computer -Force
}
}ElseIf($(Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "32-bit"){
Copy-Item $HotFix_32bit "\\$computer\c$" -Force
$cmd={
Start-Process wusa.exe -ArgumentList '"C:\Windows6.1-KB2819745-x86-MultiPkg.msu" /extract:C:\MSU\' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872035-x86.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2872047-x86.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\MSU\Windows6.1-KB2819745-x86.cab /NoRestart' -Wait
Remove-Item C:\MSU -Recurse -Force
Restart-Computer -Force
}
}
Invoke-Command -ComputerName $computer -ScriptBlock $cmd
}
Actually come to think of it, WMF4 requires Win7, Win2008R2 or Win2012. The only one of those offered in x86 is Win7, but you said it’s a server OS? Just curious about that, as perhaps this will not work regardles…