正在尝试在Powershell中登录Azure
我遵循MS指南,在我真正登录之前,一切都正常进行。弹出窗口将显示我的凭据并对其进行验证,但powershell似乎没有注意到 因此,需要安装模块、导入模块、验证版本、登录。关于最后两个步骤,请参见下文正在尝试在Powershell中登录Azure,powershell,azure,Powershell,Azure,我遵循MS指南,在我真正登录之前,一切都正常进行。弹出窗口将显示我的凭据并对其进行验证,但powershell似乎没有注意到 因此,需要安装模块、导入模块、验证版本、登录。关于最后两个步骤,请参见下文 PS C:\WINDOWS\system32> Get-Module AzureRM -ListAvailable | Select-Object -Property Name,Version,Path Name Version Path ---- ------- ---- A
PS C:\WINDOWS\system32> Get-Module AzureRM -ListAvailable | Select-Object -Property Name,Version,Path
Name Version Path
---- ------- ----
AzureRM 6.3.0 C:\Program Files\WindowsPowerShell\Modules\AzureRM\6.3.0\AzureRM.psd1
PS C:\WINDOWS\system32> Connect-AzureRmAccount
Account :
SubscriptionName :
SubscriptionId :
TenantId :
Environment :
PS C:\WINDOWS\system32>
当然,从那时起,这阻止了我在Azure上做很多其他事情
编辑:问题出现在多个工作站上您可以尝试此
Install-Module PoweshellGet -Force
Set-ExecutionPolicy -ExicutionPolicy Remotesigned
Install-Module AzureRm
Import-Module -Name AzureRm
Login-AzureRmAccount
你可以试试这个
Install-Module PoweshellGet -Force
Set-ExecutionPolicy -ExicutionPolicy Remotesigned
Install-Module AzureRm
Import-Module -Name AzureRm
Login-AzureRmAccount
您可以使用以下链接安装最新的PowerShell版本: 然后使用类似的方法自动输入用户名密码,并跳过UI:
$azureAccountName ="enter username here"
$azurePassword = ConvertTo-SecureString "password here" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)
Login-AzureRmAccount -Credential $psCred
您可以使用以下链接安装最新的PowerShell版本: 然后使用类似的方法自动输入用户名密码,并跳过UI:
$azureAccountName ="enter username here"
$azurePassword = ConvertTo-SecureString "password here" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)
Login-AzureRmAccount -Credential $psCred
您是否尝试过以下方法:
Import-Module Microsoft.Powershell.Security
$azureAccountName ="enter username here"
$azurePassword = ConvertTo-SecureString "password here" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)
$decrypt = $psCred.GetNetworkCredential()
$ptpass = $decrypt.Password
Write-Output "Logging in to Azure using $azureAccountName with a password of $ptpass"
Login-AzureRmAccount -Credential $psCred
如果您收到此代码的错误,请用完整的错误消息进行注释。您是否尝试过以下操作:
Import-Module Microsoft.Powershell.Security
$azureAccountName ="enter username here"
$azurePassword = ConvertTo-SecureString "password here" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAccountName, $azurePassword)
$decrypt = $psCred.GetNetworkCredential()
$ptpass = $decrypt.Password
Write-Output "Logging in to Azure using $azureAccountName with a password of $ptpass"
Login-AzureRmAccount -Credential $psCred
如果您收到此代码的错误,请用完整的错误消息进行注释。我唯一能想到的是以下内容 您可能使用Azure服务管理(Azure V1/Azure Classic),它使用与Azure资源管理器(ARM、Azure V2)不同的模块 要安装Azure服务管理模块:
安装模块Azure-AllowClobber
由于已安装AzureRM模块,因此允许使用clobber 将Azure模块导入PowerShell:
导入模块Azure
登录ASM:添加AzureAccount
显示所有订阅获取AzureSubscriptions
选择分配给您在其中工作的订阅选择AzureSubscription
在下面的帖子中回答了类似的问题:希望这对我有所帮助。我唯一能想到的就是下面的内容 您可能使用Azure服务管理(Azure V1/Azure Classic),它使用与Azure资源管理器(ARM、Azure V2)不同的模块 要安装Azure服务管理模块:
安装模块Azure-AllowClobber
由于已安装AzureRM模块,因此允许使用clobber 将Azure模块导入PowerShell:
导入模块Azure
登录ASM:添加AzureAccount
显示所有订阅获取AzureSubscriptions
选择分配给您在其中工作的订阅选择AzureSubscription
在下面的帖子中回答了类似的问题:希望这有帮助我也遇到了同样的问题。我有两个像你们一样的用户:Azure用户是“工作”帐户,然后是“个人”帐户,也是由Office365和Azure自动创建的。当我试图使用我的“个人”帐户时,我遇到了这个问题,我在其中添加了一些订阅(委托) 在尝试了很多之后,对我有效的方法是在“connectazurermaccount”命令要求输入用户名/密码时登录到“Work”帐户。然后,我再次使用命令“Connect AzureRMAccount”,但这次我输入了个人帐户,它终于起作用了 编辑:我后来发现的一个更好的方法是这样的,因为我从一个帐户管理大量订阅/租户(委托访问): 将“tenantid”放入一个变量中(在我的情况下,您可以在Azure门户的“更改目录”选项中获取此ID): $tenantId=“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” 指定租户ID的登录名: 登录AzureRmAccount-租户$TenantId
我收到了同样的问题。我有两个像你们一样的用户:Azure用户是“工作”帐户,然后是“个人”帐户,也是由Office365和Azure自动创建的。当我试图使用我的“个人”帐户时,我遇到了这个问题,我在其中添加了一些订阅(委托) 在尝试了很多之后,对我有效的方法是在“connectazurermaccount”命令要求输入用户名/密码时登录到“Work”帐户。然后,我再次使用命令“Connect AzureRMAccount”,但这次我输入了个人帐户,它终于起作用了 编辑:我后来发现的一个更好的方法是这样的,因为我从一个帐户管理大量订阅/租户(委托访问): 将“tenantid”放入一个变量中(在我的情况下,您可以在Azure门户的“更改目录”选项中获取此ID): $tenantId=“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” 指定租户ID的登录名: 登录AzureRmAccount-租户$TenantId
您可以尝试使用服务主体凭据登录 服务主体是在Active Directory下创建的应用程序,您可以对其应用权限规则
$pscredential = Get-Credential
Connect-AzureRmAccount -ServicePrincipal -ApplicationId "http://my-app" -Credential $pscredential -TenantId $tenantid
有关详细信息,请参阅。您可以尝试使用服务主体凭据登录 服务主体是在Active Directory下创建的应用程序,您可以对其应用权限规则
$pscredential = Get-Credential
Connect-AzureRmAccount -ServicePrincipal -ApplicationId "http://my-app" -Credential $pscredential -TenantId $tenantid
有关更多详细信息,请参阅。此行为在您运行时发生
Clear-AzureRMContext -Scope CurrentUser
我不知道为什么,我正在尝试调试如何解决这个问题。解决方法是关闭powershell窗口,然后重新打开未运行此命令的新powershell窗口
运行命令
Enable-AzureRmContextAutosave -Scope CurrentUser
Enable-AzureRmContextAutosave -Scope Process
为我解决了这个问题。这将自动保存每个powershell会话的上下文。如果不需要,可以运行该命令
Enable-AzureRmContextAutosave -Scope CurrentUser
Enable-AzureRmContextAutosave -Scope Process