如何使用 Powershell 在浏览器中启动所有 azure webapps

How to launch all azure webapps in a browser using Powershell

我试图在我的 azure 帐户上获取所有 webapps/sites 的 url 并在 Internet Explorer 中启动它们。我一直遇到错误:

Value does not fall within the expected range.

我确定我遗漏了一些小东西,但就是想不通。请看下面的代码。

$list = Get-AzureRmWebApp

foreach ($i in $list)
{
    $link = $list.DefaultHostName
    $Browser=new-object -com internetexplorer.application
    $Browser.navigate2($link, 0x1000 )
    $Browser.visible=$true
}

您需要在 foreach 循环中引用 $i.DefaultHostName,而不是整个 $list.

$list = Get-AzureRmWebApp

foreach ($i in $list)
{
    $link = $i.DefaultHostName
    $Browser=new-object -com internetexplorer.application
    $Browser.navigate2($link, 0x1000 )
    $Browser.visible=$true
}