Monthly Archives: February 2016

Locate VMware snapshots with PowerCLI

Summary
PowerCLI is a scripting toolkit for vSphere and vCenter within a PowerShell console. You can use it to manage and report on vSphere and vCenter servers.

Installation
Find v5 here (requires a My VMware login) or search for latest version. Launch the installer, no reboot is required.

Using PowerCLI
Once installed look for the following icon in the Apps screen.

powercli-icon

This will launch the PowerCLI console (run as a user that has admin rights on the VMware environment. In mine LDAP authentication is enabled so I run the PowerCLI as a domain admin account.

PowerCLI Commands

connect-VIServer -server <server-fqdn> (This is required before you can run any commands. It will always try to to use SSO for connection to a vCenter server, not for ESXi hosts)

disconnect-VIServer * or Disconnect-VIServer <server-fqdn>

$global:DefaultVIServer use this command to determine what host you are connected to.

get-datacenter Get the datacenter for the the current connection

get-cluster Get the cluster for the the current connection

get-vm | Get-Snapshot | select VM,Name,Created | sort created Find all VMware snapshots that have been deteled/released once the backup is complete

get-vm | Get-Snapshot | select VM,Name,Created | Where {$_.name -Like “smvi*”} | sort created Find all NetApp snapshots that have been deteled/released once the backup is complete

Get-VM | Export-CSV -Path <filename.csv> Export data