【问题标题】:Route Table Details路由表详细信息
【发布时间】:2021-09-14 03:18:24
【问题描述】:

有没有办法使用路由表名称、订阅、下一跳类型地址前缀从每个订阅中获取路由的所有详细信息。

我已尝试 'Get-AzRouteTable -ResourceGroupName "" -Name "prod" |获取 AzRouteConfig | Export-Csv azureroutetable2.csv' 但只能从特定环境中获取,有没有更好的方法来做同样的事情?

问候

开发者

【问题讨论】:

    标签: azure powershell azure-devops


    【解决方案1】:

    根据Get-AzRouteTable 的帮助,它不需要为ResourceGroupName 指定任何值,因此我们应该能够遍历您可用的上下文。如果您确实拥有大型 Azure 网络基础架构,并且它们在逻辑上按资源组进行组织,您可能还需要考虑循环通过资源组。

    话虽如此,你可以做这样的事情。它将为您当前会话中的每个订阅创建一个 csv。如果您愿意,可以更改路径值开头的 . 以设置完整路径。

    $Contexts = Get-AzContext -ListAvailable
    foreach ($Context in $Contexts) {
        [void](Set-AzContext -SubscriptionId $Context.Subscription.Id)
        $RouteConfig = Get-AzRouteTable -Name "prod" | Get-AzRouteConfig
        # If you are using PowerShell 5.1, add '-NoTypeInformation' to the end of this command.
        $RouteConfig | Export-Csv -Path ".\$($Context.Subscription.Name)_Routes.csv" -Encoding utf8 -NoClobber
    }
    

    【讨论】:

      猜你喜欢
      • 2020-09-04
      • 1970-01-01
      • 2011-01-25
      • 1970-01-01
      • 2020-05-11
      • 2021-05-01
      • 2014-01-02
      • 1970-01-01
      • 2014-12-15
      相关资源
      最近更新 更多