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

Microsoft Cloud – A couple of pages to help ... Cloud is the hot-topic in our industry nowadays and Microsoft has been delivering great products for this demand: the Window Server itself (the Cloud ...
How to move your workloads to Azure When integrating your on-premises environment with Azure, you might want to use the lift-and-shift approach to migrate some of your existing workloads...
Windows Azure and Office 365 – Getting a fre... In this first article we will go over the process to subscribe on both Office365 and Windows Azure, and after that in our following Tutorials we will ...
AAD Sync – Modifying a filter rule How to modify an existent filter rule and validating what changes in the Azure Active Directory using AAD Sync. Solution To demonstrate how a ...