buffalix
Contributor
Contributor

reference to custerom field in select statement

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

0 Kudos
1 Reply
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos