即使我可以看到虚拟网络,仍然无法从 Azure powershell1.4.0 获取特定的虚拟网络子网信息。
PS C:\Users\mwang> Get-AzureRmVirtualNetwork |more |选择字符串名称|more
名称:ToolBelt ResourceGroupName:ToolBelt “名称”:“ToolBelt_GTPROD.local”, “名称”:“ToolBelt_GTPROD”, “名称”:“TestVNet ResourceGroupName:BI-Reporting-VPN “名称”:“FrontEnd”, “名称”:“Backend”, “名称”:“GatewaySubnet”, “名称”:“GTGLOBAL.LOCAL ResourceGroupName:GTGLOBAL “名称”:“GTGLOBAL1”, “名称”:“GatewaySubnet”, “名称”:“NetworkLoadBalancer”, “名称”:“BarracudaLB”, “名称”:“DMZ”, “名称”:GTLB ResourceGroupName:GTLB “名称”:“default”, “名称”:KW-network ResourceGroupName:KW “名称”:“default”,
PS C:\Users\mwang> Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork KW-network Get-AzureRmVirtualNetworkSubnetConfig:无法绑定参数“VirtualNetwork”。无法将“System.String”类型的“KW-network”值转换为“Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork”类型。在第 1 行,字符:55 + Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork KW-network + ~~~~~~~~~~ + CategoryInfo:InvalidArgument:(:) [Get-AzureRmVirtualNetworkSubnetConfig],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Network.GetAzureVirtualNetworkSu bnetConfigCommand
PS C:\Users\mwang> Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork GTGLOBAL.LOCAL Get-AzureRmVirtualNetworkSubnetConfig:无法绑定参数“VirtualNetwork”。无法将“System.String”类型的“GTGLOBAL.LOCAL”值转换为“Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork”类型。在第 1 行,字符:55 + Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork GTGLOBAL.LOCAL + ~~~~~~~~~~~~~~ + CategoryInfo:InvalidArgument:(:) [Get-AzureRmVirtualNetworkSubnetConfig],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Network.GetAzureVirtualNetworkSu bnetConfigCommand
PS C:\Users\mwang>
答案1
错误明确指出它无法绑定字符串值。它应该作为变量传递。下面是一个例子
$vnetname=Get-AzureRmVirtualNetwork -Name <value> -ResourceGroupName <value>
现在将此变量传递给 getsubnet 命令,如下所示:
Get-AzureRmVirtualNetworkSubnetconfig -VirtualNetwork $vnetname
答案2
您在最后一次调用中传递了错误的参数:
Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork GTGLOBAL.LOCAL
它应该是这样的:
Get-AzureRmVirtualNetwork "GTGLOBAL.LOCAL" | Get-AzureRmVirtualNetworkSubnetConfig ...