移除AzureRmRouteConfig和x27;不要像Get AzureRmRouteConfig那样处理where对象

移除AzureRmRouteConfig和x27;不要像Get AzureRmRouteConfig那样处理where对象,azure,powershell,Azure,Powershell,获取具有预期名称的所有路由配置。例如,USGovginia_1 Get-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"} Get-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"} 给出了这个错误 Remove-AzureRmRouteConfig -RouteTable $rt

获取具有预期名称的所有路由配置。例如,USGovginia_1

Get-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"}
Get-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"}
给出了这个错误

Remove-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"}

我一直在尝试使用PowerShell处理Route table,因此我想了解为什么它不起作用

它不起作用的原因是管道从左到右工作,即命令从左输入到右下一个

在您的情况下,您正在尝试在选择路由之前删除它

尝试下面的代码(最后还要注意Set-AzureRmRouteTable,因为除非最后执行Set命令,否则不会应用您的更改)

您也可以查看Microsoft文档上的一个示例-

在第一个命令中,首先获取路由,然后选择与路由顶部的模式/应用过滤器匹配的特定路由,以使其正常工作

$rt = Get-AzureRmRouteTable -ResourceGroupName "your route table - resource group name"

Get-AzureRmRouteConfig -RouteTable $rt | where-object {$_.Name -like "*virginia*"} | ForEach-Object
 {Remove-AzureRmRouteConfig -RouteTable $rt -Name $_.Name | Set-AzureRmRouteTable}
在第二个命令中,首先尝试删除路由,然后选择与上面的模式/应用过滤器匹配的特定路由,因此失败

Get-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"}
Remove-AzureRmRouteConfig -RouteTable $rt | Where-Object {$_.Name -like "*virginia*"}