Uninstall previous versions of PowerShell module

Prerequisites

The PowerShellModuleName variable must already be defined or one of the following values must be set:

Exchange Online

$PowerShellModuleName = 'ExchangeOnlineManagement'

Run the following commands to retrieve the latest version of the PowerShell module in PSGallery: 

$ModuleInGallery = Find-Module -Name $PowerShellModuleName

Run the following commands to retrieve the versions of the PowerShell module on the local system: 

$ModulesOnSystem = Get-Module -ListAvailable -Name $PowerShellModuleName

Run the following commands to review the previous versions of the PowerShell module on the local system: 

Run the following commands to remove the previous versions of the PowerShell module on the local system: 

Â