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 locate the name of the active PowerShell modulemodules:

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

Run the following commands to locate the installed PowerShell modules :

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

...

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

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

To install the module:

Code Block
languagepowershell

...

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

...

To update the module:

...

languagepowershell

...

 } Else { Install-Module -Name $PowerShellModuleName }