Newbie : Select AvailableField property?

This topic contains 1 reply, has 2 voices, and was last updated by  Joe Acosta 2 weeks, 6 days ago.

  • Author
    Posts
  • #84647

    George Gl
    Participant

    Hi everyone,
    I got a newbie question to ask:
    I'm trying to list VMs with associated snapshots and a a field from their Annotations.
    So far I've done this Get-View -ViewType VirtualMachine -Filter @{"snapshot" = ""} | Where {-not $_.Config.Template} | select name

    and the Property I'm trying to reference is the Ansprechpartner value from AvailabeField :
    Capability : VMware.Vim.VirtualMachineCapability
    Config : VMware.Vim.VirtualMachineConfigInfo
    Layout : VMware.Vim.VirtualMachineFileLayout
    LayoutEx : VMware.Vim.VirtualMachineFileLayoutEx
    Storage : VMware.Vim.VirtualMachineStorageInfo
    EnvironmentBrowser : EnvironmentBrowser-envbrowser-9087
    ResourcePool : ResourcePool-resgroup-132
    ParentVApp :
    ResourceConfig : VMware.Vim.ResourceConfigSpec
    Runtime : VMware.Vim.VirtualMachineRuntimeInfo
    Guest : VMware.Vim.GuestInfo
    Summary : VMware.Vim.VirtualMachineSummary
    Datastore : {Datastore-datastore-27}
    Network : {Network-network-52}
    Snapshot : VMware.Vim.VirtualMachineSnapshotInfo
    RootSnapshot : {VirtualMachineSnapshot-snapshot-9127}
    GuestHeartbeatStatus : green
    LinkedView :
    Parent : Folder-group-v8157
    CustomValue : {103, 104, 105, 108...}
    OverallStatus : green
    ConfigStatus : green
    ConfigIssue : {}
    EffectiveRole : {-1}
    Permission : {}
    Name : TQA-WIN-D040212
    DisabledMethod : {Destroy_Task, UnregisterVM, UnmountToolsInstaller, AnswerVM...}
    RecentTask : {}
    DeclaredAlarmState : {alarm-10.vm-9087, alarm-11.vm-9087, alarm-1201.vm-9087, alarm-1301.vm-9087...}
    TriggeredAlarmState : {}
    AlarmActionsEnabled : True
    Tag : {}
    Value : {103, 104, 105, 108...}
    AvailableField : {Ablaufdatum, Ansprechpartner, Bereitstellungsdatum, DB-Name...}
    MoRef : VirtualMachine-vm-9087
    Client : VMware.Vim.VimClientImpl

    Any suggestions?

    Thanks

  • #84653

    Joe Acosta
    Participant

    Something along the lines of:

    $OneVM = Get-View -ViewType VirtualMachine -Filter @{"snapshot" = ""} | Where {-not $_.Config.Template} | select -first 1
    $AField = $OneVM.AvailableField  |? Key -match Ansprechpartner
    $OneVM.Name
    $OneVM.Guest.HostName
    $Afield
    $Afield.WhateverPropertiesYouWant
    

    Put some combo of the above and whatever you want into a custom object or whatever it is you are trying to make. Note this example is purposely for one VM. For more, omit the select -first 1 statement, then loop thru the variable that you store the first statement in. Example:

    $AllVM = Get-View -ViewType VirtualMachine -Filter @{"snapshot" = ""} | Where {-not $_.Config.Template}
    ForEach ($vm in $allVM) {$vm.Name, etc, etc.}	
    

You must be logged in to reply to this topic.