Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PowerShell for Windows patch apply
$patches = get-item $foldername
$process = new-object System.Diagnostics.Process
foreach($patch in $patches){
if($PSVersionTable.PSVersion.Major -ge 4) {
unblock-file $patch
}
if([string]::compare($patch.extension, ".exe", $true) -eq 0) {
$process.StartInfo.Arguments = "/passive /norestart"
$process.StartInfo.FileName = $patch.fullname
}else if([string]::compare($patch.extension, ".msu", $true) -eq 0) {
$process.StartInfo.Arguments = $patch.fullname + " /quiet /norestart"
$process.StartInfo.FileName = "wusa.exe"
} else {
continue
}
$process.Start()
$process.WaitForExit()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment