您好我有这个脚本登录 - 列出订阅 - 选择订阅并选择资源组并继续我的脚本。
Write-Host -ForegroundColor White "Login with your Azure Account"
Add-AzureRmAccount
Write-Host -ForegroundColor DarkYellow "Your Available Subscriptions"
Get-AzureRmSubscription | Select-Object -ExpandProperty Name
$subscriptions = @(Get-AzureRmSubscription | Select-Object -ExpandProperty Name)
$flag = $true
while ($flag) {
Write-Host -ForegroundColor Green 'Enter target Subscription name :' -NoNewline
$subscriptionName = Read-Host
foreach ($temp in $subscriptions) {
if ($temp -eq $subscriptionName) {
Select-AzureRmSubscription -SubscriptionName $subscriptionName
$flag = $false
break
}
}
if ($flag -eq $true) {
Write-Host -ForegroundColor Red "Enter valid Subscription name"
}
}
Write-Host -ForegroundColor White "Selected Subscription is : " -NoNewline
Write-Host -ForegroundColor Green $subscriptionName
Write-Host -ForegroundColor White 'Your Available Resource Groups'
Get-AzureRmResourceGroup | Select-Object -ExpandProperty ResourceGroupName
$resourceGroups = @(Get-AzureRmResourceGroup | Select-Object -ExpandProperty ResourceGroupName)
$flag = $true
while ($flag) {
Write-Host -ForegroundColor Green 'Enter target Resource group name :' -NoNewline
$resourceGroupName = Read-Host
foreach ($temp in $resourceGroups) {
if ($temp -eq $resourceGroupName) {
Set-AzureRmResourceGroup -Name $resourceGroupName -Tag @{}
$flag = $false
break
}
}
if ($flag -eq $true) {
Write-Host -ForegroundColor Red "Enter valid Resource group name"
}
}
Write-Host -ForegroundColor DarkYellow "Selected Resource group is : "$resourceGroupName
当我在Windows 8机器上运行上述脚本时,它工作正常,我可以选择MPN订阅。但是当我在Windows 10机器上运行相同的脚本时,它会抛出错误,指出请提供有效的租户或有效订阅
附图供参考 - https://imgur.com/a/H5d8D