Last active
August 29, 2015 14:04
-
-
Save kkamegawa/88ac2220b31be925b44b to your computer and use it in GitHub Desktop.
PowerShell for Windows patch apply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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