Search code examples
powershellvirtual-machinevspherepowercli

Editing Annotations In VSphere Using PowerShell


I need to be able to edit the Annotations of VMs from powershell(ps) as will be editing many at once Image. I found "AvailibleField" after getting VM view in ps Image but not sure how to edit these. Can anyone help? Thanks :)


Solution

  • I think what you're looking for is the Get/Set-Annotation cmdlets: http://www.vmware.com/support/developer/PowerCLI/PowerCLI651/html/Set-Annotation.html

    Example:

    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>