How to connect to Azure PowerShell (ARM & Azure AD)

  • Connect to ARM using the Azure RM modules.
  • Connect to Azure AD using the Azure AD module.

How to connect to Azure ARM:

run command $PSVersionTable.PSVersion and confirm the Major build is 5

un command Install-Module AzureRM

You will be prompted to install NuGet if you have a version earlier than 2.8.5.201 or do not have it at all. Type y and press Enter.

To trust the PowerShell Gallery as a repository, type a and press Enter.

command Import-Module AzureRM

run command Connect-AzureRmAccount

Run a test command such as Get-AzureRmTenant and confirm that they issue correctly.

How to save credentials across PowerShell sessions:

credentials issue command Enable-AzureRmContextAutosave

running command Get-AzureRmContext

If you want to remove a particular context issue command Remove-AzureRmContext -Name <name>

If you want to remove all saved context, run command Disconnect-AzureRmAccount

Additional commands:

  • Get a list of AzureRm related modules – Get-Module Azure*
  • Get a list of cmdlets – Get-Command -Module Azure*
  • Update the Azure PowerShell module – Update-Module -Name AzureRM
  • Connect to an Azure China or Germany tenant – Connect-AzureRmAccount -Environment AzureChinaCloud for example.

How to connect to Azure AD

run command Install-Module MSOnline  Type Y and press Enter

Now run command Connect-MsolService

Sign in with Azure AD administrator credentials

Run command Import-Module MSOnline

You can now run a number of PowerShell cmdlets to manage your Azure AD environment

Get-AzureRmResource | Export-CSV C:\temp\azure-resources.csv

REDMOR https://docs.microsoft.com/en-gb/powershell/module/azurerm.resources/?view=azurermps-6.13.0

https://docs.microsoft.com/en-us/powershell/azure/active-directory/overview?view=azureadps-2.0

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WhatsApp Logo IT World