I have been working on automating my organizations Active Directory/Exchange user provisioning, and needed a method to easily log what actions are taken. To accomplish this, I decided to write a couple PowerShell logging functions that I could integrate into my other functions for creating the user, creating the mailbox, generating approval emails, and assigning groups. The functions I came up with are Start-Log, Write-Log, and Stop Log.
Perhaps the most fundamental DBA task is to configure proper SQL maintenance on all of your instances. There are many ways to approach this, including SSIS-based GUI-driven maintenance plans, custom homebrewed T-SQL scripts, PowerShell scheduled jobs, or third-party applications. However, my (and many other’s) preferred solution is to use Ola Hallengren’s fantastic maintenance scripts (ola.hallengren.com). This solution is recommended by many people for good reason. It provides a good amount of flexibility, compatibility, as well as a solid amount of logging. You can use this solution right out of the box and it will work great, but I like to tweak it a bit to better fit my needs and be a little easier to apply.
One of the first things I check when I get to the office in the morning is any SQL agent jobs that failed overnight. Our monitoring system will also pick these up, but I like to have a condensed report with the failed production jobs, job step(s) that failed, and error message so that I can quickly diagnose what went wrong. We already had a script in place which mostly worked, based on this, but I wanted to modify it a bit to return some more useful information.