Safe Restart Script – Part 2

PoShAs 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"

Continue reading “Safe Restart Script – Part 2”

Safe Restart Script

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.PoSh

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”