Azure powershell - 从资源属性中选择子属性

问题描述 投票:0回答:1

我想在 IP 配置/子网下仅选择名称和 Id,但不知道是否可行。请帮助或指出我正确的方向。

这是命令和输出。


PS C:\Users\aarora> Get-AzVirtualNetworkGateway -ResourceGroupName rg-vwan -Name as-vnet-gateway-rb-s2s


Name                            : as-vnet-gateway-rb-s2s
ResourceGroupName               : rg-vwan
Location                        : centralus
Id                              : /subscriptions/xxx/resourceGroups/rg-vwan/providers/Microsoft.Network/virtualNetworkGateways/texas-vnet-gateway-rb-s2s
Etag                            : W/"76489c17-50c5-49b5-9d65-19280e98718e"
ResourceGuid                    : e49c4f7f-3123-497e-8257-dd1f8c943e1c
ProvisioningState               : Succeeded
Tags                            :
IpConfigurations                : [
                                    {
                                      "PrivateIpAllocationMethod": "Dynamic",
                                      "Subnet": {
                                        "Id": "/subscriptions/xxx/resourceGroups/rg-vwan/providers/Microsoft.Network/virtualNetworks/vnet-am-rb-s2s/subnets/GatewaySubnet"
                                      },
                                      "PublicIpAddress": {
                                        "Id": "/subscriptions/xxx/resourceGroups/rg-vwan/providers/Microsoft.Network/publicIPAddresses/pub-ip-as-rb-s2s"
                                      },
                                      "Name": "default",
                                      "Etag": "W/\"76489c17-50c5-49b5-9d65-19280e98718e\"",
                                      "Id": "/subscriptions/xxx/resourceGroups/rg-vwan/providers/Microsoft.Network/virtualNetworkGateways/as-vnet-gateway-rb-s2s/ipConfigurations/default"
                                    }
                                  ]
azure powershell azure-virtual-network
1个回答
0
投票

当我尝试相同的命令时,我得到了相同的结果:

$gatewayInfo = Get-AzVirtualNetworkGateway -ResourceGroupName hedwig -Name vpn1

enter image description here

要在 IP 配置/子网下仅选择名称和 Id,请使用以下命令:

Get-AzVirtualNetworkGateway -ResourceGroupName <RGNAME>-Name <vpnnAME> | Select-Object -ExpandProperty IpConfigurations | Select-Object -Property Name, @{Name="SubnetId";Expression={$_.Subnet.Id}}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.