How to connect to Microsoft Azure using PowerShell

Share this:

In Today’s tutorial, we are going over the process to connect your Windows 10/Windows Server 2016 in Microsoft Azure to manage your tenant.

In the past, we had to install components on the Operating System (we may have if you are using older versions) to get the connection from your workstation to Microsoft Azure, but that is not the case with the latest OSes, such as Windows 10 and Windows Server 2016.

If you are studying for the exam 70-533: Implementing Microsoft Azure Infrastructure Solution or 70-535: Architecting Azure Solutions, it is good to understand and practice this process explained here.


The process to connect on Azure is done through the PowerShellGet module, and this module is responsible to interact with the PowerShell Gallery. You may be wondering what is PowerShell Gallery, right? It is a central repository for commands (modules) and DSC (Desired State Configuration) resources, you an find more about that by accessing this link here:

The first step, is to check the module installed locally, running the following cmdlet. The output of this cmdlet will provide information about the current version, brief description and where it is installed (the file itself).

Get-Module PowerShellGet –list | fl


Installing AzureRM Module..

Now that we have the means to download and use modules from the PowerShell Gallery, we can use the following cmdlet to install the AzureRM which will enable the cmdlets to manage services from Microsoft Azure.

Install-Module AzureRM

Make sure that you are running as administrator, and you may be asked to trust the repository, make sure that you confirm.


After confirmation the download of the dependent packages will continue, give some time and wait for completion.


In order to validate the current module (version and file), we can run the following cmdlet:

Get-Module AzureRM -list | fl


Managing Modules..

In some situations, the administrator may want to install a different version from the latest, using the following cmdlet we can install the version 5.0.0 for example.

Install-Module AzureRM -RequiredVersion 5.0.0

In order to load the module of any given version, we an run the following cmdlet.

Import-Module AzureRM -Version 5.0.0

The entire process of installing a specific version, listing all modules on the local machine and using a specific module are depicted in the image below.


Understanding Modules in PowerShell

If you are curious to see what is running on your current session, run the following cmdlet, and a list of all loaded modules will be listed.


To list all modules available for use in your machine, the following cmdlet can be used:

Get-Module –ListAvailable


Connecting to Microsoft Azure..

The final step is to connect to our Microsoft Azure tenant, and that can be done using the cmlet below and a prompt to authenticate will be displayed.





It is all about Security…

Security is a must, and we need to policy ourselves around security best practices and some potential risks that may be involved in any given process. Here are some of the topics from the top of my head that we should be aware in the topic covered in this tutorial. If you are studying for Security certifications that may give you in some insights:

  • If you are connecting to Microsoft Azure to manage, make sure that you have MFA (Multiple Factor Authentication) enabled
  • We are connecting to PowerShell Gallery, so make sure that your DNS resolution is working correctly, and you are not expose to DNS Spoofing (Pharming attack)
  • Just in case, if you are a security freak, check your host file to make sure that it is clean and not compromised as well
  • Last but not least, make sure that your machine is free of any malware and with the AV up-to-date.

Written by Anderson Patricio

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange and several other certifications. Anderson has been contributing to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at,, and Anderson (Portuguese).

Related Post

Containers on Azure – Part 1 In the last decade, hardware virtualization has drastically changed the IT landscape. One of many consequences of this trend is the emergence of cloud...
PowerShell Script to fix Exchange Server 2013 Secu... I wrote the following PowerShell script to help fixing the issue reported by Microsoft Exchange Team (
How to delegate access in Hyper-V In some medium/large organizations, it is common practice to have different access levels for systems, such as administrator, help desk, support and a...
Azure Site Recovery Azure Site Recovery (ASR) is by far one of the Azure features that I always like to play with. The improvement along the time is above extraordinaire!...