VMware Cloud Community
bvial
Contributor
Contributor
Jump to solution

How to get the href for an object returned from 'search-cloud'

I am currently running the following search-cloud to get Org VDC Network.

$network = Search-Cloud -QueryType OrgVdcNetwork -Name 'my_network_name'

I then want to get the href of this object. But, this is not visible in the object returned:

PS C:\powershell\VCDProduction\GenericScripts> $a
 
 
Name               : Customer_90533-V550-Mortgag_DEV_UAT-M2VLN25342003
DefaultGateway     : 172.23.25.254
Netmask            : 255.255.255.0
Dns1               :
Dns2               :
DnsSuffix          :
LinkType           : 0
ConnectedTo        : Customer_90533-V550-Mortgag_DEV_UAT-M2VLN25342003
Vdc                : urn:vcloud:vdc:ae96fdb6-b2df-4884-911f-c19e24953b4f
IsBusy             : False
IsShared           : True
VdcName            : M2VDC25342013
IsIpScopeInherited : True
Href               :
Id                 : urn:vcloud:network:f55f6db0-e099-45d5-88eb-8192e00e9618
Type               :
AnyAttr            : {taskStatus, taskOperation, task, taskDetails}
Link               :
Metadata           :
PropertyList       : {[Name, Customer_90533-V550-Mortgag_DEV_UAT-M2VLN25342003], [DefaultGateway, 172.23.25.254],
                     [Netmask, 255.255.255.0], [Dns1,  ]...}
Uid                : /CIServer=custdccreator:system@10.135.2.33:443/CISearchResult=18de8709-af31-4c2a-90b7-4596c43457c2
                     /
Client             : /CIServer=custdccreator:system@10.135.2.33:443/

PS C:\powershell\VCDProduction\GenericScripts> $a


Name               : my_network_name
DefaultGateway     : 192.168.1.254
Netmask            : 255.255.255.0
Dns1               :
Dns2               :
DnsSuffix          :
LinkType           : 0
ConnectedTo        : my_network_name
Vdc                : urn:vcloud:vdc:ae96fdb6-b2df-4884-911f-c19e24953b4f
IsBusy             : False
IsShared           : True
VdcName            : my_vdc_name
IsIpScopeInherited : True
Href               :
Id                 : urn:vcloud:network:f55f6db0-e099-45d5-88eb-8192e00e9618
Type               :
AnyAttr            : {taskStatus, taskOperation, task, taskDetails}
Link               :
Metadata           :
PropertyList       : {[Name, my_network_name], [DefaultGateway, 192.168.1.254],
                     [Netmask, 255.255.255.0], [Dns1,  ]...}
Uid                : /CIServer=custdccreator:system@x.x.x.x:443/CISearchResult=18de8709-af31-4c2a-90b7-4596c43457c2
                     /
Client             : /CIServer=custdccreator:system@x.x.x.x:443/

0 Kudos
1 Solution

Accepted Solutions
jitrocs
Contributor
Contributor
Jump to solution

Not a straight-forward approach, but you can try this to solve your problem:

// Search for all OrgVdcNetwork

$s_orgvdcnetwork = Search-Cloud -QueryType OrgVdcNetwork

// Filter the network name you want to match

$q = $s_orgvdcnetwork | Where-Object {$_.Name -match '^network-name$'}

//FInally, use OrgVdcNetwork command to access the Href

Get-OrgVdcNetwork -Name $q.Name | select href

HTH.

View solution in original post

0 Kudos
1 Reply
jitrocs
Contributor
Contributor
Jump to solution

Not a straight-forward approach, but you can try this to solve your problem:

// Search for all OrgVdcNetwork

$s_orgvdcnetwork = Search-Cloud -QueryType OrgVdcNetwork

// Filter the network name you want to match

$q = $s_orgvdcnetwork | Where-Object {$_.Name -match '^network-name$'}

//FInally, use OrgVdcNetwork command to access the Href

Get-OrgVdcNetwork -Name $q.Name | select href

HTH.

0 Kudos