azure - 连接-AzureRmAccount : Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'

标签 azure powershell automation cloud

简单地说,我在 Azure 中使用 runbook 自动化运行 Connect-AzureRmAccount,它给出了以下错误:

Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'.

我已经导入了 Azureprofile 模块,但我无法弄清楚问题是什么。

最佳答案

如果你想在 Runbook 中使用 PowerShell 命令 Connect-AzureRmAccount 连接到 Azure 帐户,那么确实没有必要。正如我在评论中所说,当您使用 Runbook 时,您已经拥有帐户的租户的精确订阅。因此,只需运行脚本而不连接帐户即可。

如果您确实想使用 PowerShell 连接,可以像这样使用服务主体:

Disable-AzureRmContextAutosave –Scope Process

$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationID $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint

但我真的建议您直接运行 Runbook 中的 PowerShell 脚本。

更新

创建 Runbook 时,将有一个连接供您运行 PowerShell 脚本。或者您可以根据需要创建连接。请参阅Connection assets in Azure Automation 。您可以只使用默认连接,使用如下代码:

$connectionName = "AzureRunAsConnection"
try
{
    # Get the connection "AzureRunAsConnection "
    $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName         

    "Logging in to Azure..."
    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
    }
}

关于azure - 连接-AzureRmAccount : Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54272880/

相关文章:

azure - 服务结构不健康的服务影响其他服务

powershell - 使用 PowerShell 脚本和 CSOM 在 SharePoint Online 中设置网站 Logo

ssis - 如何使用命令行从 biml 生成 ssis 包并在服务器上部署 ssis

c# - 为什么使用 PUBSUB 订阅时无法 PING 通?

windows - 虚拟机 - Azure,设置 Web 服务器

azure - 网站与新 Azure 门户中的 webrole 应用程序有何不同

powershell - VSTS 构建定义 - 防止导致进程终止的 PowerShell 退出行为

powershell - Out-GridView 显示一个空白列,其中有实际数据

vb.net - 让鼠标光标移动到一个位置?

angularjs - 我们可以使用 TestCafe 来自动化 angular 或 reactjs 应用程序吗?