【问题标题】:Add-AzureRmAccount : Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'Add-AzureRmAccount:无法在 DLL“iphlpapi.dll”中找到名为“GetPerAdapterInfo”的入口点
【发布时间】:2020-02-07 16:00:55
【问题描述】:

我正在运行 Azure 自动化运行手册,它具有 PowerShell 脚本以按定义的计划重新启动 Azure Web 应用程序。在测试运行以下脚本时出现错误:

$connectionName = "AzureRunAsConnection"
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName
$null = Add-AzureRmAccount ` 
    -ServicePrincipal ` 
    -TenantId $servicePrincipalConnection.TenantId ` 
    -ApplicationId $servicePrincipalConnection.ApplicationId ` 
    -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint

$null = Select-AzureRmSubscription -SubscriptionId 'SubscriptionID'

Restart-AzureRmWebApp -ResourceGroupName 'RGroupName' -Name 'webappname'

错误详情:

Add-AzureRmAccount:无法在 DLL“iphlpapi.dll”中找到名为“GetPerAdapterInfo”的入口点。

  • $null = 添加-AzureRmAccount
  • CategoryInfo : CloseError: (:) [Connect-AzureRmAccount], AadAuthenticationFailedException
  • FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

这个错误是否与没有足够的访问权限有关?

谢谢!

【问题讨论】:

    标签: powershell azure-web-app-service azure-runbook


    【解决方案1】:

    我可以用你的脚本重现这个问题。

    要解决此问题,请将您的脚本更改为以下脚本,它会正常工作。

    注意:导航到您的自动化帐户 -> Modules -> 确保模块 AzureRM.ProfileAzureRM.Websites 存在,如果不存在,请单击 Browse Gallery 搜索并导入.

    $connectionName = "AzureRunAsConnection"
    try
    {
        # Get the connection "AzureRunAsConnection "
        $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName         
    
        "Logging in to Azure..."
        $null = Add-AzureRmAccount `
            -ServicePrincipal `
            -TenantId $servicePrincipalConnection.TenantId `
            -ApplicationId $servicePrincipalConnection.ApplicationId `
            -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint 
    }
    catch {
        if (!$servicePrincipalConnection)
        {
            $ErrorMessage = "Connection $connectionName not found."
            throw $ErrorMessage
        } else{
            Write-Error -Message $_.Exception
            throw $_.Exception
        }
    }
    
    $null = Select-AzureRmContext -Subscription 'SubscriptionID'
    Restart-AzureRmWebApp -ResourceGroupName 'RGroupName' -Name 'webappname'
    

    【讨论】:

    • 谢谢!我想我在从另一个文档复制脚本时也几乎没有非法字符。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    相关资源
    最近更新 更多