Often a Sysadmin creates a checkpoint (snapshot) of the VM before they doing some changes. Our Servicedesk wants to monitor those snapshots so they don’t get to big or even stays there for ever. We used Orchestrator to create a simple check against the VMM Server and send out a mail with the current snapshot overview.
We achieved this by creating a runbook with 2 simple steps:
First we run a Powershell script. and output this to a e-mail.
When we take a closer look at the Powershell script we created it as followed:
The script contains the following lines:
1 2 3 4 5 6 7 |
$vmcheck = Get-VM | where { $_.LastRestoredVMCheckpoint -like "* *" } [string]$body = "<table border=0>`n" $body += "<tr><td>Name</td><td>CheckPoint</td><td>Location</td></tr>`n" foreach ($vm in $vmcheck) { $body += ("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>`n" -f ($vm.name, $vm.LastRestoredVMCheckPoint, $vm.CheckPointLocation)) } $body += "</table>`n" |
For the email template we created a html with the following lines. The bold part should be a published data from the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<html> <head> <title>Snapshot Overview</title> </head> <body> <p> <img src=http://www.ourwebsite/images/logo.png align=left /> <img src=http://www.ourwebsite/images/microsoft.jpg align=right /> <br /><br /><br /><br /> <center><h2 font face="Segoe UI Light">Virtual Machine Snapshot Overview </h2></center> </p> <br /><br /><br /><br /> {Output Variable 01 from "Run VMM Powershell Script"} </body> </html> |
When we start the runbook tester and click run we got a e-mail with an overview of the Virtual Machines having a snapshot:
I like to use SCOJobRunner for scheduled runbook activities what I defined on my Runbook Server. I created a new scheduled task and assign the runbook ID from the runbook we just created to run every day at 6:45am