Practical PowerShell Azure,PowerShell Remove AzureRM and Install AZ Module for Azure PowerShell Management

Remove AzureRM and Install AZ Module for Azure PowerShell Management

For this PowerShell Tip of the Week I wanted to review the process for removing AzureRM from a computer and installing the new AZ module for managing you Azure environment. In the post we will also walk through some troubleshooting tips if there are any issues in the process of removal / installation.

First, remove base modules:
[sourcecode language=”powershell”]
uninstall-module Azure
uninstall-module AzureRM
[/sourcecode]
The check what we have left:


Remove the rest:
[sourcecode language=”powershell”]
$Modules = Get-Module -ListAvailable | Where {$_.Name -like 'AzureRM.*'}
Foreach ($Module in $Modules) {Uninstall-Module $Module}
[/sourcecode]
Try to install the AZ module and receive an error:


Remember that this is an older server and Microsoft changed TLS settings a while back. Let’s verify what TLS version we have:


Well, that won’t do at all. Let’s bump that up:


And now the install proceed as expected.

If there are issues during the install you may need to add a couple of switched in order for the install to complete:
[sourcecode language=”powershell”]
Install-Module AZ -AllowClobber -Force
[/sourcecode]
Install should look like this:


Now, if there are issues with an install, we can also change the $DebugPreference variable from ‘SilentlyContinue’ to a value of ‘Continue’:
[sourcecode language=”powershell”]
$DebugPrefernce = 'Continue'
[/sourcecode]
This can create a rather noisy screen output when performing tasks, so be aware:


To change it back, simply execute:
[sourcecode language=”powershell”]
$DebugPrefernce = 'SilentlyContinue'
[/sourcecode]

Importing the Module


Once we have the new AZ module installed we can load it and start connecting, managing and configuring our Azure resources:
[sourcecode language=”powershell”]
Import-Module AZ
[/sourcecode]
With the mpodule imported we can verify our list of mpodules:
[sourcecode language=”powershell”]
Get-Module AZ* | fw
[/sourcecode]
and see this:

Conclusion

While the above article shows the removal of the old AzureRM module and an installation of the new AZ module (with some effort), this is not necessarily required. This was written for an server where I no longer wanted to have the AzureRM module installed and also wanted to prevent clobber as the current server uses PowerShell 5.1. If you are using PowerShell 6.x, you should be able to deploy these in parallel and not have any issues with cmdlet clobber or conflicts. For my workstation above, it’s time for an upgrade – it’s running Windows 2016, but an old version of PowerShell.

Related Post