Last active
April 2, 2025 14:45
-
-
Save irelandjoe/bced724575dae3f97cf623637911e492 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ResourceGroupName="ALClus01-RG" | |
| $Location="eastus" | |
| #login to azure | |
| #download Azure module | |
| Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | |
| if (!(Get-InstalledModule -Name az.accounts -ErrorAction Ignore)){ | |
| Install-Module -Name Az.Accounts -Force | |
| } | |
| #login using device authentication | |
| Connect-AzAccount -UseDeviceAuthentication | |
| #assuming new az.accounts module was used and it asked you what subscription to use - then correct subscription is selected for context | |
| $Subscription=(Get-AzContext).Subscription | |
| #install az resources module | |
| if (!(Get-InstalledModule -Name az.resources -ErrorAction Ignore)){ | |
| Install-Module -Name az.resources -Force | |
| } | |
| #create resource group | |
| if (-not(Get-AzResourceGroup -Name $ResourceGroupName -ErrorAction Ignore)){ | |
| New-AzResourceGroup -Name $ResourceGroupName -Location $location | |
| } | |
| #output all info | |
| Write-Host "" ; Write-Host "SubscriptionID: " -ForegroundColor Cyan -NoNewLine ; Write-Host "$($Subscription.ID)" ; Write-Host "ResourceGroup Name : " -ForegroundColor Cyan -NoNewLine ; Write-Host "$ResourceGroupName" ; Write-Host "Region: " -ForegroundColor Cyan -NoNewLine ; Write-Host "$Location" ; Write-Host "TenantID: " -ForegroundColor Cyan -NoNewLine ; Write-Host "$($Subscription.TenantID)" ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment