Monday, December 15, 2014

Who Rebooted?

Run this PowerShell and substitute the actual server name instead of SQLTACOPS-05 to find out who rebooted in the last 155 days.  This code was posted by Tompa on Technet before I tweaked it for my use.

Who_Rebooted

Thursday, September 11, 2014

Las Vegas SQL Server User Group

Thanks, Jason and Stacia, for allowing me to present tonight!

Here are the materials from the presentation, including bonus favorite scripts/functions.

PowerShell: The Way of the DBA Dragon – presentation scripts and slide deck.
imageimage

I used Start-Demo to play back the commands to avoid typing.

Thursday, July 03, 2014

Favorite Function for Checking Disk Space in PowerShell–includes Mountpoints and System Reserved Volumes

Found a superior function and added a parameter to check disk space compared to the old script I was using.

function df { Param([string[]]$ComputerName) Get-WMIObject Win32_Volume -filter "DriveType=3" -computer $ComputerName | Select SystemName,Caption,Label,@{Name="DiskSize(GB)";Expression={[decimal]("{0:N1}" -f($_.capacity/1gb))}},@{Name="freespace(GB)";Expression={[decimal]("{0:N1}" -f($_.freespace/1gb))}},@{Name="PercentFree(%)";Expression={"{0:P2}" -f(($_.freespace/1gb)/($_.capacity/1gb))}}}

Here’s an example of omitting system reserved volumes and passing multiple servernames in a text file:

image