Skip to content

Instantly share code, notes, and snippets.

@kkamegawa
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkamegawa/88ac2220b31be925b44b to your computer and use it in GitHub Desktop.
Save kkamegawa/88ac2220b31be925b44b to your computer and use it in GitHub Desktop.
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