【发布时间】:2018-07-12 07:17:55
【问题描述】:
我写了一个小脚本,它显示了一些关于虚拟机的信息。
$vsms = Get-VM
$erg = $vsms | Select-Object -Property @{N="VmName"; E={$_.Name}},
@{N="Power"; E={$_.PowerState}},
@{N="CustomTag1"; E={$_.CustomFields.Item("CustomTag1")}},
@{N="Customtag2"; E={$_.CustomFields.Item("Customtag2")}},
@{N="Customtag3"; E={$_.CustomFields.Item("Customtag3")}},
@{N="ProvisionedSpaceGB"; E={[math]::Round($_.ProvisionedSpaceGB)}}, `
@{N="UsedSpaceGB"; E={[math]::Round($_.UsedSpaceGB)}},
@{N="IP Address";E={@($_.guest.IPAddress[0])}}
$erg | Sort-Object VmName | Export-Csv $outputPath -NoType
我的问题是如何扩展此脚本 以获取有关还原点的信息(创建时间等...)。以及如何将结果导出为 csv,以便所有创建时间和其他属性都在每个 vm 的一个单元格/行中?结果应该像我已经做的那样导出为csv。 它应该是这样的:
VmName | SnapshotCreationTime| ... other properties
testvm | 19:17 01.02.18, 19:17 02.02.18,... | other properties
testvm2| 19:17 08.02.18, 19:17 02.03.18,... | other properties
不是:
VmName | SnapshotCreationTime| other properties (already in script)
testvm | 19:17 01.02.18, | other properties
testvm | 19:17 02.02.18, | other properties
testvm | 19:17 03.02.18, | other properties
testvm2| 19:17 08.02.18, | other properties
testvm2| 19:17 09.02.18, | other properties
testvm2| 19:17 10.02.18, | other properties
【问题讨论】:
标签: powershell csv virtual-machine vmware snapshot