解决了

通过脚本列出当前快照


你好,
我是Nutanix的新手,有一个问题。

有人知道是否有一种方法可以通过脚本列出所有当前快照?

我想找出是否有任何挥之不去的快照。

感谢您可能提供的任何建议。
图标

最好的答案Andymlloyd2019年8月19日,13:45

@nfrederickx<\/user-mention> Hi,
\n
\nYou 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:
\n
\n## Simple Nutanix All Last Snapshot info Script ##
\n## Andy Lloyd ##
\n
\n$nutsnaps=Get-NTNXSnapshot
\n$allnutvms=Get-NTNXVM | select uuid,vmName
\nforeach ($snap in $nutsnaps)
\n{
\n$vmname= ($allnutvms | where {$_.Uuid -eq $snap.vmUuid}).vmName
\n$snaptime=$snap.createdtime\/1000
\n$snapdt=(Get-Date '1\/1\/1970').AddMilliseconds($snaptime)
\n$actualsnapdt=$snapdt.ToLocalTime()
\n##Write-host $actualsnapdt
\n#Write-host $snap.snapshotname
\nWrite-host \"VM: \" -nonewline; write-host $vmname -foregroundcolor yellow -nonewline; Write-Host \" Last Snapshot Name: \" -nonewline; `
\nwrite-host $snap.snapshotname -foregroundcolor Yellow -nonewline; Write-Host \" Taken: \" -nonewline; Write-host $actualsnapdt -foregroundcolor Yellow
\n}
\n
\nIf this helps you out please mark as Best Answer and Like 🙂
\nMany thanks
\nAndy","className":"post__content__best_answer"}">
查看原件

该主题已关闭以供评论

2个答复

看起来可能有效:https://chrisjeucken.com/2018/07/query-all-snapshots-from-nutanix-ahv/
UserLevel 2
徽章 +2
@nfrederickx你好,

您可以使用PowerShell cmdlet获得VM名称,VM快照名称和日期/时间的非常简单的输出。下面的脚本应该整理出来:

##简单nutanix全部快照信息脚本##
## Andy Lloyd ##

$ nutsnaps = get-ntnxsnapshot
$ allnutvms = get-ntnxvm |选择uuid,vmname
foreach($ nutsnaps中的$ snap)
{
美元
$ snaptime = $ snap.createdtime/1000
$ snapdt =(get-date'1/1/1970')。addmilliseconds($ snaptime)
$ actualsnapdt = $ snapdt.tolocaltime()
##写入主持人$ mualthsnapdt
#写入主持人$ snap.snapshotname
写入主持人“ vm:” -nonewline;写入主持人$ vmname -foregroundColor Yellow -noneWline;写入主持人“最后一个快照名称:” -nonewline;`
写入host $ snap.snapshotname-foregroundercroundColor Yellow -noneWline;写入主持人“ take:” -nonewline;写入主持人$ muthatesnapdt-前景彩色黄色
}

如果这有帮助您,请标记为最佳答案,喜欢
非常感谢
安迪
Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu