I haven't run this code but I think it should do what you're trying to accomplish:
$UpdatePath = "C:\Updates"
Get-HotFix > "$UpdatePath\Old_HotFix_List.txt"
$installed = (Get-HotFix).HotFixID
Get-ChildItem -Path $UpdatePath -Include *.msu |
ForEach-Object{
if ($_.Name -match "^.+-(kb[^-]+)-"){ # name looks like "windows10.0-kb5003537-x86-ndp48_0f7a496cc7e0dc08f0494e8c9e3c6a83a9175e97.msu"
$kbid = $matches[1]
if ($installed -contains $kbid)
{
Write-Host "Windows Update '$kbid' Already Installed on Computer "
}
else{
$UpdateFilePath = $_.FullName
write-host "Installing Update '$kbid' on Computer $update"
Start-Process -wait wusa -ArgumentList "/update $UpdateFilePath","/quiet","/norestart"
}
}
else{
Write-Host "Did not find KB number in the filename '$_'"
}
}
Get-HotFix > "$UpdatePath\New_HotFix_List.txt"
timeout 5
shutdown /r
Note that the variable "$update" (which should hold the name of the computer on which to run "wsua") is undefined. You should also check that "wsua" is sufficient to start the process.