Scheduled task to run a PowerCLI script (and delete a named snapshot)
Posted: August 3, 2012 Filed under: PowerShell / PowerCLI, VMware, Windows | Tags: delete snapshot, powercli, scheduled, scheduled task, script, snapshot 1 CommentI had occasion recently to delete a snapshot at a certain time. It’s easy enough to schedule the snapshot using the vSphere Client and built-in functions, but then, how to delete it on a schedule? Enter PowerCLI and the Windows Task Scheduler.
There was a VMTN forum post by Duncan Epping (@DuncanYB) that suggested using the generic form Get-VM | Get-Snapshot | Remove-Snapshot. This worked a charm for me and I put it into the following script.
Add e-mail alerts to all 41 default vSphere 4.1 alarms
Posted: November 3, 2011 Filed under: PowerShell / PowerCLI, VMware | Tags: add email alerts, alarms, alerts, email, Get-AlarmAction, Get-AlarmDefinition, New-AlarmAction, New-AlarmActionTrigger, notification email, powercli, script, scripting, vcenter, vsphere 4 CommentsTowards the end of a customer’s virtualization implementation we’re doing some clean-up of the environment. During the initial setup I was using my own local email address to test various alerting processes, of which there are several. For instance, every SQL Server maintenance task sends a success/failure e-mail alert, the NetApp Virtual Storage Console plug-in can be configured to e-mail an administrator after snapshots are taken, and the Dell iDRAC can send e-mails on hardware status changes. All those are fairly quick to configure or lack a way to script a quick solution. But with 40 default alarms in vSphere, three vCenters, and being lazy as I am, I knew there must be a better solution than right clicking 120 alarms and copying-and-pasting an email address. As the proverb goes, if you repeat it, script it. So I set out to find how PowerCLI could help me.