Automation

 View Only
  • 1.  reference to custerom field in select statement

    Posted May 14, 2014 03:50 PM

    I currently have this statement to show some of the attributes

    $vms = Get-VM | sort-object name | select name, powerstate, host, NumCpu, MemoryMB, Notes | convertto-html

    but I want to include a customed attributed URL, so how do I reference this attribute in the select statement? The following does not work - noticing I am trying to reference it as  CustomFields.URL

    $vms = Get-VM | sort-object name | select name, powerstate, CustomFields.URL, host, NumCpu, MemoryMB, Notes | convertto-html

    Thanks a lot

    Frank



  • 2.  RE: reference to custerom field in select statement

    Posted May 14, 2014 05:46 PM

    Try like this (with a calculated property)

    $vms = Get-VM | sort-object name | select name, powerstate, @{N="URL";E={$_.CustomFields["URL"]}}, host, NumCpu, MemoryMB, Notes | convertto-html

    But I suspect putting an URL in there might have some possible side-effects on the ConvertTo-Html