List current snapshots via a script | Nutanix Community
Skip to main content
Hi,

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.
Looks like this may work: https://chrisjeucken.com/2018/07/query-all-snapshots-from-nutanix-ahv/
@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 ##



$nutsnaps=Get-NTNXSnapshot

$allnutvms=Get-NTNXVM | select uuid,vmName

foreach ($snap in $nutsnaps)

{

$vmname= ($allnutvms | where {$_.Uuid -eq $snap.vmUuid}).vmName

$snaptime=$snap.createdtime/1000

$snapdt=(Get-Date '1/1/1970').AddMilliseconds($snaptime)

$actualsnapdt=$snapdt.ToLocalTime()

##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

Andy