I was able to pull in a json with invoke-webrequest.
When I look at $x.y.z.ipaddress, it displays two values. one is our public and one backup. How can I assign the public IP to $PubIP There is an object $x.y.z.networkType that defines the public vs backup.
something like...
$PubIP = $x.y.z.ipaddress(Where $x.y.z.networktype = public)
$BkpIP = $x.y.z.ipaddress(Where $x.y.z.networktype = backup)
Thank you!
$PubIP = ($x.y.z | Where-Object {$_.networktype -eq "public"}).ipaddress
$BkpIP = ($x.y.z | Where-Object {$_.networktype -eq "backup"}).ipaddress
Probably something like this if I'm extrapolating from your post correctly.
Can you show us the object you imported?
With something like ' $x.y.z | Format-Custom -Depth 2'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is from $x.y.z | format-custom -depth 2
class PSCustomObject
{
workorder_id =
serverinfo_id = 36971
netmask = 255.255.255.0
default_gw = 10.10.10.1
ip_address = 10.10.10.78
id =
target_hostname =
network_type = PUBLIC
suffix =
port_group =
server_farm_name =
seczonename =
networkinfo_id = 46730
}
class PSCustomObject
{
workorder_id =
serverinfo_id = 36971
netmask = 255.255.255.0
default_gw = 10.11.11.1
ip_address = 10.11.11.241
id =
target_hostname =
network_type = BK
suffix =
port_group =
server_farm_name =
seczonename =
networkinfo_id = 46731
}
Thank you... This worked!
I was so close... LOL