Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #one time setup.  Run the folowing as admin answering Yes to the prompt
  2. #Install-Module PSWindowsUpdate
  3. $dt = [DateTime]::Now
  4. $dt
  5. $fl="C:\logs\patchserver-{0:M-d-yyyy}.log"-f $dt
  6. $fl
  7. get-service W3SVC| Stop-Service 4>&1 |Out-File $fl -Append
  8. if ((Get-Service W3SVC).Status -eq "Running"){
  9.  
  10. Write-Error "IIS still running.  Run script again once stopped."4>&1 |Out-File $fl -Append
  11. exit
  12. }
  13. Import-Module PSWindowsUpdate -verbose 4>&1 |Out-File $fl -Append
  14. write-host "IIS stopped" 4>&1 |Out-File $fl -Append
  15. write-host "Installing updates" 4>&1 |Out-File $fl -Append
  16.  
  17. Get-WUInstall -AcceptAll -Install -AutoReboot -verbose 4>&1 |Out-File $fl -Append
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement