Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell管理多个AzureRM帐户_Powershell_Azure_Azure Resource Manager - Fatal编程技术网

如何使用Powershell管理多个AzureRM帐户

如何使用Powershell管理多个AzureRM帐户,powershell,azure,azure-resource-manager,Powershell,Azure,Azure Resource Manager,我尝试使用登录AzurerAccount并添加AzurerAccount以登录到我的Azure帐户。我有两个,可以通过add AzureAccount轻松添加这两个帐户,并使用Select Azuresubscription管理活动帐户和默认帐户 使用RM cmdlet,每当我添加AzurerAccount时,它都会覆盖上一个经过身份验证的帐户。这使得我很难在私人和公司azure帐户之间切换 有什么解决办法吗? 我正在使用PowerShell Gallery更新Azure和AzureRM模块,并

我尝试使用登录AzurerAccount并添加AzurerAccount以登录到我的Azure帐户。我有两个,可以通过add AzureAccount轻松添加这两个帐户,并使用Select Azuresubscription管理活动帐户和默认帐户

使用RM cmdlet,每当我添加AzurerAccount时,它都会覆盖上一个经过身份验证的帐户。这使得我很难在私人和公司azure帐户之间切换

有什么解决办法吗?
我正在使用PowerShell Gallery更新Azure和AzureRM模块,并使用最新的模块。

官方方法是这样做

$profile1 = Login-AzureRmAccount 
$profile2 = Login-AzureRmAccount

Select-AzureRmProfile -Profile $profile2
然后,您可以使用将配置文件保存到磁盘

Save-AzureRmProfile -Profile $profile1 -Path e:\ps\profile1.json 
然后可以加载

Select-AzureRmProfile -Path e:\ps\profile1.json 

不过,我个人的方法是创建一个模块,该模块提供了一个以profile1、profile2等作为参数的cmdlet。然后,它将下载并解密凭据,并将它们输入Add-AzureRMAccount(这样我可以从不同的位置使用相同的凭据文件)

使用登录AzureRMAccount分别登录两个帐户。然后使用获取AzureRmSubscription检查订阅信息并记下两个租户

要在私人和公司azure帐户之间切换,可以使用

 $loadersubscription = Get-AzureRmSubscription -SubscriptionName $YourSubscriptionName -TenantId $YourAssociatedSubscriptionTenantId