Did I Leave a VM on?

Ever wrap up a demo or end a day of development work and wonder if you left a VM running in Azure?  Yep, I’ve done that.  I’ve also NOT wondered about it, completely forget even, and ended up running a VM for some time without thinking about it.  I have two subscriptions I routinely use for demos and development and for the most part have no reason to have cores running in those subscriptions if I’m not actively doing something.  A real quick PowerShell script let’s me know at the end of the day if something is up or not.

Get-AzureSubscription -ExtendedDetails | ? { $_.CurrentCoreCount -gt 0 } | ft -Property  SubscriptionName, CurrentCoreCount

I’ve put this into my PowerShell Profile as a function named Get-CoreCount.  It doesn’t tell me what is running, or where, but I will recognize subscription names that shouldn’t have anything going.  If I see something I don’t expect I’ll spin up Azure Management Studio to take a look and take action if necessary.

Now…did I leave the gas on at the house?