我想访问“IpConfigurations”中的“PrivateIpAddress”参数的值。我该怎么做?当我选择“IpConfigurations”(下面的命令1)时,默认显示IPConfigurations->Name参数值(命令2->IpConfigurations->Name)。但我想访问IpConfigurations->PrivateIPAddress值。
命令1:
PS C:> Get-AzureRmNetworkInterface -ResourceGroupName $myResourceGroup | Select Name, ResourceGroupName, IpConfigurations
Name ResourceGroupName IpConfigurations
---- ----------------- ----------------
zzz01.zzz.com-nic01 test-rg {zzz01.zzz.com-nic01-ipconfig}
命令2:
PS C:> Get-AzureRmNetworkInterface -ResourceGroupName $myResourceGroup
Name : zzz01.zzz.com-nic01
ResourceGroupName : test-rg
Location : xxxx
Id : /xxxx
Etag : xxxxxx
ResourceGuid : xxxx
ProvisioningState : Succeeded
Tags :
VirtualMachine : {
"Id": "/subscriptions/xxxx
}
IpConfigurations : [
{
"Name": "zzz01.zzz.com-nic01-ipconfig",
"Etag": "W/\"xxxx",
"Id": "xxxxxxx",
"PrivateIpAddress": "10.65.179.179",
......
}
]
DnsSettings : {
"DnsServers": [],
"AppliedDnsServers": [],
"InternalDomainNameSuffix": "xxxx.net"
}
EnableIPForwarding : False
EnableAcceleratedNetworking : False
NetworkSecurityGroup : null
Primary : True
MacAddress : xxxxx
答案1
我无法访问 Azure,因此无法访问您的命令,但也许下面类似的命令可以起作用:
(Get-AzureRmNetworkInterface -ResourceGroupName $myResourceGroup|Get-NetIPConfiguration).PrivateIpAddress