Windows Server 2012: Hyper-V Snapshot Reminder

Windows Server 8

Last year I created a Windows PowerShell script for System Center Virtual Machine Manager which checks all the Virtual Machines for Snapshots and if you have any it will send you an E-Mail and it will remind you about that.
It were just some small changes from the SCVMM PowerShell cmdlets to the Windows Server 2012 PowerShell cmdlets.

Hyper-V Snapshots Reminder

# Get Snapshots
$snapshots = Get-VM | Get-VMSnapshot
# Check for existing Snapshots
if ($snapshots.count -gt 0){
    # Create the List of Snapshots
    $info = $snapshots | Format-Table VMName, Name -auto | Out-String
    # Mail Configuration
    # ==================
    # Configuration
    $emailFrom = "[email protected]"
    $emailTo = "[email protected]"
    $emailSubject = "VM Snapshot Reminder"
    $emailMessage = "You have still some snapshots: `n `n" + $info + "`n Greetings your Hyper-V Server"
    $smtpServer = ""
    $smtpUserName = "username" # This could be also in e-mail address format
    $smtpPassword = "password"
    $smtpDomain = ""
    # SMTP Object
    $smtp = New-Object System.Net.Mail.SmtpClient($smtpServer)
    $mailCredentials = New-Object System.Net.NetworkCredential
    $mailCredentials.Domain = $smtpDomain
    $mailCredentials.UserName = $smtpUserName
    $mailCredentials.Password = $smtpPassword
    $smtp.Credentials = $mailCredentials 
    # Send E-Mail
    $smtp.Send($emailFrom, $emailTo, $emailSubject, $emailMessage)