List current snapshots via a script

  • 29 April 2019
  • 2 replies

I`m very new to Nutanix and have a question.

Does anyone know if there is a way to list all current snapshots via a script?

I`d like to find out if there are any lingering snapshots that should be removed.

Thanks for any advice you might have.

Best answer by andymlloyd 19 August 2019, 13:45

View original

This topic has been closed for comments

2 replies

Looks like this may work:
Userlevel 2
Badge +2
@nfrederickx Hi,

You can get a very simple output of VM Name, VM Snapshot Name and Date/Time taken using the Powershell Cmdlets. Script below should sort you out:

## Simple Nutanix All Last Snapshot info Script ##
## Andy Lloyd ##

$allnutvms=Get-NTNXVM | select uuid,vmName
foreach ($snap in $nutsnaps)
$vmname= ($allnutvms | where {$_.Uuid -eq $snap.vmUuid}).vmName
$snapdt=(Get-Date '1/1/1970').AddMilliseconds($snaptime)
##Write-host $actualsnapdt
#Write-host $snap.snapshotname
Write-host "VM: " -nonewline; write-host $vmname -foregroundcolor yellow -nonewline; Write-Host " Last Snapshot Name: " -nonewline; `
write-host $snap.snapshotname -foregroundcolor Yellow -nonewline; Write-Host " Taken: " -nonewline; Write-host $actualsnapdt -foregroundcolor Yellow

If this helps you out please mark as Best Answer and Like 🙂
Many thanks