Skip to content

Instantly share code, notes, and snippets.

@vbjay
Created June 11, 2020 01:55
Show Gist options
  • Save vbjay/41db534e1fcc5409a5af44fe11a6a85c to your computer and use it in GitHub Desktop.
Save vbjay/41db534e1fcc5409a5af44fe11a6a85c to your computer and use it in GitHub Desktop.
install updates
#one time setup. Run the folowing as admin answering Yes to the prompt
#Install-Module PSWindowsUpdate
$dt = [DateTime]::Now
$dt
$fl="C:\logs\patchserver-{0:M-d-yyyy}.log"-f $dt
$fl
get-service W3SVC| Stop-Service 4>&1 |Out-File $fl -Append
if ((Get-Service W3SVC).Status -eq "Running"){
Write-Error "IIS still running. Run script again once stopped."4>&1 |Out-File $fl -Append
exit
}
Import-Module PSWindowsUpdate -verbose 4>&1 |Out-File $fl -Append
write-host "IIS stopped" 4>&1 |Out-File $fl -Append
write-host "Installing updates" 4>&1 |Out-File $fl -Append
Get-WUInstall -AutoReboot -AcceptAll -Install -verbose 4>&1 |Out-File $fl -Append
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment