In this video, we go over how to get scheduled events for an Azure virtual machine by querying the Instance Metadata service API endpoint with a PowerShell Scheduled Task. That data is then sent to a Log Analytics Workspace to be queried or alerted on.Continue reading “Get Azure Scheduled Events with IMDS”
As promised, here is the safe restart PowerShell script version that includes writing output to the Event Log.
I used the Write-Eventlog command to get the output into the event log. I started by defining the variables. The eventID and eventSource can be anything, eventLog and eventType need to match the parameters of the Write-Eventlog command.
#eventlog vars $eventLog = "System" $eventType = "Information" $eventID = 212 $eventSource = "SafeRestart"
This is a script that reboots if day and time criteria are met and if the uptime is less than a given number of days.
I had, what I thought, was a simple request. I wanted any servers that had not rebooted as part of the monthly SCCM patch cycle to reboot at the end of the maintenance window. This way I know that the servers don’t have any unfinished patching and the servers have a reboot in the last 30 days. These are Windows servers and I’m old school, I like to routinely reboot them. Continue reading “Safe Restart Script”