« Linux Media Center ServerRetrieve directory size with Powershell »

Powershell Find VM with snapshots


Powershell Find VM with snapshots

Permalink 11:00:00 am by vappsnl, Categories: Personal

To get an overview of Virtual Machines with snapshots and put the outcome in an htm-file you can use the following script:

$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: blue;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:darkgrey}"
$a = $a + "TD{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"
Connect-viserver vcs02

Get-VM | Get-Snapshot | select VM,Id,SizeMB | ConvertTo-Html -Head  $a -PreContent 'Existing Snapshots' | Out-File c:\snapshot.htm
Invoke-Expression c:\snapshot.htm

Disconnect-VIServer vcs02 -Confirm:$false

This is how the output could look like in your browser: