Created
June 11, 2020 01:55
-
-
Save vbjay/41db534e1fcc5409a5af44fe11a6a85c to your computer and use it in GitHub Desktop.
install updates
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
#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