Exercise 1 – installing Azure PowerShell
In this section, you’ll learn how to install the Azure PowerShell module.
The following steps must be carried out on the OS of a machine you have admin access to; this could be physical or virtual. We are using a Windows 10 device for this exercise – Windows 10 Pro 20H2 using PowerShell 7 for reference:
- On your device, search for Windows PowerShell 7 and click Open.
Figure 6.15 – Searching for PowerShell
2. Check the version of PowerShell by running the following command from within PowerShell:
$PSVersionTable.PSVersion
The output will look as follows:
Figure 6.16 – PowerShell version
3. Enter the following command; the PowerShell script execution policy must be set to remote signed or less restrictive:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Confirm this using the following command:
Get-ExecutionPolicy -List
The output will be as follows:
Figure 6.17 – Setting the execution policy
4. Enter the following command to install the Az module:
Install-Module -Name Az -AllowClobber -Scope CurrentUser -Repository PSGallery -Force
The following screenshot shows the installation progress:
Figure 6.18 – PowerShell version
You will see the following when the Az module is imported if the version of PowerShell you’re using is not supported:
“This version of Az.Accounts is only supported on Windows PowerShell 5.1 and PowerShell 7.0.6 or greater, open https://aka.ms/install-powershell to learn how to upgrade. For further information, go to https://aka.ms/azpslifecyle.”
Enter the following command to check the version of the PowerShell module that’s been installed:
Get-InstalledModule -Name Az
The output will look as follows:
Figure 6.19 – PowerShell module version
5. Enter the following to update all the Powershell modules to their latest versions:
Update-Module
6. The following command will update the Azure PowerShell module:
Update-Module -Name Az
In this exercise, we looked at installing the Azure Powershell module. We will install the Azure CLI in the following exercise.