添加 AzureRmAccount:无法在 DLL 'iphlpapi.dll' 中找到名为 'GetPerAdapterInfo' 的入口点
Add-AzureRmAccount : Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'
我是 运行 Azure Automation Runbook,它具有 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
此错误是否与访问权限不足有关?
谢谢!
我可以用你的脚本重现这个问题。
要解决此问题,请将您的脚本更改为以下脚本,它将正常运行。
注意:导航到您的自动化帐户 -> Modules
-> 确保模块 AzureRM.Profile
、AzureRM.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'
我是 运行 Azure Automation Runbook,它具有 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
此错误是否与访问权限不足有关?
谢谢!
我可以用你的脚本重现这个问题。
要解决此问题,请将您的脚本更改为以下脚本,它将正常运行。
注意:导航到您的自动化帐户 -> Modules
-> 确保模块 AzureRM.Profile
、AzureRM.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'