In this blog i will share with you script and other resources that you can use to automate patching.
- Script to check list of all Windows updates installed – Run this from orchestrator against all the servers to verify patches that were successfully applied and one’s which failed – PowerShell script to list all installed Microsoft Windows Updates
- Incase you want to use directly windows update and not use SCCM then this script will come to your help – Install Microsoft Updates using Powershell
- To check computers where reboot was added as a step in orchestrator however still sccm says that computer reboot pending – Get-PendingReboot – Query Computer(s) For Pending Reboot State You can also use this in scenarios where sccm is scheduled to only push patches and not reboot systems
- Run a SQL query to check patching compliance status – Get the Update Compliance Status for multiple Update groups against Multiple collections using SQL query without reporting You can run this using SQL read database activity in orchestrator. Script needs to be modified as per your enviroment
- Script to create multiple DBs in SQL where you will be storing your ‘SteptoExecute’ and ‘ExecutedSteps’ – SQL Script to create DBs
- Script to check web application status code – Auto Web Application response status code checker
- PS command to confirm that a server reboot is successful –
Restart-Computer -ComputerName REMOTE_COMPUTER_NAME -Force – Wait WinRM
This will force server to restart and return a success code only after the server restarts and WinRM service is up and running. This will ensure that the steps that you have arranged to be executed after a server reboot happens correctly and they do not get failed.
Like i said i in my earlier Patching by Orchestrator Part -1 Blog that i am unable to share complete runbooks or scripts that i have used due to NDA with my employer.
If you know of more script or other innovative ways of automating patching then please post them in comments section.
Note: Credit and risk for all the script and links that i have mentioned here goes to their respective authors.