Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Prerequisites

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

Expand
titleCommon PowerShell module names
Info

Exchange Online

Code Block
languagepowershell
$PowerShellModuleName = 'ExchangeOnlineManagement'

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

Code Block
languagepowershell
$ModuleInGallery = Find-Module -Name $PowerShellModuleName

Run the following commands to

...

retrieve the versions of

...

the PowerShell module on the local system

Code Block
languagepowershell
$InstalledModules$ModulesOnSystem = Get-InstalledModule; ForEach ($Module in $InstalledModules) { Get-InstalledModule -Name $Module.Name -AllVersions | WhereModule -ListAvailable -Name $PowerShellModuleName

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

Code Block
languagepowershell
$ModulesOnSystem | ForEach-Object { If ($_.Version -lt $ModuleInGallery.Version) { $_ } }

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

Code Block
languagepowershell
$ModulesOnSystem | ForEach-Object { If ($_.Version -nelt $Module$ModuleInGallery.Version) }{ $_ | Uninstall-Module } }