【发布时间】:2017-09-22 15:23:34
【问题描述】:
我需要能够从 powershell(ps) 编辑 VM 的注释,因为将同时编辑多个 Image。在 ps Image 中获取 VM 视图后,我找到了“AvailibleField”,但不知道如何编辑这些。任何人都可以帮忙吗?谢谢:)
【问题讨论】:
标签: powershell virtual-machine vsphere powercli
我需要能够从 powershell(ps) 编辑 VM 的注释,因为将同时编辑多个 Image。在 ps Image 中获取 VM 视图后,我找到了“AvailibleField”,但不知道如何编辑这些。任何人都可以帮忙吗?谢谢:)
【问题讨论】:
标签: powershell virtual-machine vsphere powercli
我认为您正在寻找的是 Get/Set-Annotation cmdlet:http://www.vmware.com/support/developer/PowerCLI/PowerCLI651/html/Set-Annotation.html
例子:
PS C:\Users\kruddy> Get-VM file02 | select CustomFields
CustomFields
------------
{[CompanyName, ]}
PS C:\Users\kruddy> Get-VM file02 | Get-Annotation
AnnotatedEntity Name Value
--------------- ---- -----
file02 CompanyName
PS C:\Users\kruddy> Set-Annotation -Entity (Get-VM file02) -CustomAttribute CompanyName -Value TempCorp -Confirm:$false
AnnotatedEntity Name Value
--------------- ---- -----
file02 CompanyName TempCorp
PS C:\Users\kruddy> Get-VM file02 | Get-Annotation
AnnotatedEntity Name Value
--------------- ---- -----
file02 CompanyName TempCorp
PS C:\Users\kruddy> Get-VM file02 | select CustomFields
CustomFields
------------
{[CompanyName, TempCorp]}
PS C:\Users\kruddy>
【讨论】: