【发布时间】:2016-12-27 18:11:17
【问题描述】:
我正在尝试使用 PowerCLI 获取其 Uid 与“XYZ”不匹配的 VMWare 快照列表。
为此,我编写了以下代码。
$body +=echo ""`r`n""`r`n"-----Open VMware snapshots other than Uid 'XYZ'-----"`r`n""`r`n""
Get-VM | Get-snapshot | where {($_.Uid -notmatch 'XYZ')} | ForEach-Object {
$object=New-Object -TypeName PSObject -Property @{
VM_Name = $_.VM
Created = $_.Created
Size = "$([math]::Round($_.SizeGB, 2)) GB"
SnapshotName = $_.name
Description = $_.extensiondata.description
}
$body += $object | ft | out-string
Write-Output $object
}
在 PowerCLI 中运行该代码会返回所有 VMWare 快照,包括 Uid 为“XYZ”的快照,这是不应该发生的。
如何修改代码?
【问题讨论】: