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'

Install the PowerShell module

Run the following commands to verify the NuGet provider is installed:

...

Code Block
languagepowershell
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted

Modify then run Run the following commands to define the name locate any installed instance of the PowerShell module :

Code Block
languagepowershell
If ([string]::IsNullOrEmpty($PowerShellModuleName)) { $PowerShellModuleName = 'ExchangeOnlineManagement' }$ModuleIsInstalled = Get-Module -Name $PowerShellModuleName -ListAvailable

Run the following commands to locate any active instance of the PowerShell modulesmodule:

Code Block
languagepowershell
$Found$ModuleIsActive = Get-Module -Name $PowerShellModuleName -ListAvailable

Run the following commands to unload any active instance of the PowerShell modulesmodule

Code Block
languagepowershell
If ($ModuleIsActive) { Remove-Module -Name $PowerShellModuleName -Force }

Run the code blocks in one of the following sections commands to update or install the latest version of the PowerShell modules module from the PSGallery: 

...

Code Block
languagepowershell

...

If ($ModuleIsInstalled) { Update-Module -Name $PowerShellModuleName

...

To update the module:

...

languagepowershell

...

 -Verbose } Else { Install-Module -Name $PowerShellModuleName -Verbose }