Windows updates won't install

Hello All,

I’m trying to copy four patches and install them on a few remote servers (there’s no WSUS or SCCM in the environment). Copy to the remote computers is happening just fine, but, the install isn’t happening , I have this so far, please let me know if you have any inputs/suggestions

$UpdatePath = Get-ChildItem \\computername\updates

$computers= get-content -path "C:\Users\administrator\Desktop\server.txt"

foreach ($pc in $computers) {

foreach ($update in $updatepath) {

Copy-Item -Path $update.FullName -Destination "\\$pc\c$\Windows\Temp" -Force -Recurse

$UpdateFilePath = $update.FullName

Invoke-Command –ComputerName $pc –ScriptBlock { start-process -wait wusa -ArgumentList "/update $updatefilepath","/quiet","/restart"}

}

}

dbapathu,
Welcome to the forums.

Your scriptblock does not know about the variables you define outside of it. Try this:

Invoke-Command –ComputerName $pc –ScriptBlock { start-process -wait wusa -ArgumentList "/update $USING:updatefilepath", "/quiet", "/restart"}
4 Likes