ARM Templates are written with JSON and are at the core of Azure Resource Manager deployments. I have used and developed templates for months. Although successful, I ran into issues with formatting and syntax this week and decided to take a step back and get a better understanding of the underlying JSON used in these templates. In this post, I start from the beginning, exploring JSON as it relates to ARM templates. Continue reading “JSON and ARM Templates”
Odds are, you were Googling something like ‘write event log PowerShell’ and you stumbled on this page. If that’s the case and you just want to write an event to the Event Log to test something like a monitoring or alerting app, I won’t disappoint, below is what you need to know. If you want a little more information on writing to the Event Log as part of a script, keep going.
Write-eventlog requires 4 parameters, EventID, LogName, Message and Source. It’s the -Source part that trip people up. If you don’t know what the source is, simply make one up. Create the new source with the New-Eventlog command like this:
New-EventLog -LogName <Log you are writing to> -Source ‘Make one up’
For example, Adding the source HAL to the application log looks like this:
New-EventLog -LogName Application -Source ‘HAL’
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”