Prerequisites
The PowerShellModuleName variable must already be defined or one of the following values must be set:
Expand |
---|
title | Common PowerShell module names |
---|
|
Code Block |
---|
| $PowerShellModuleName = 'ExchangeOnlineManagement' |
|
Install the PowerShell module
Run the following commands to verify the NuGet provider is installed:
...
Code Block |
---|
|
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 |
---|
|
If ([string]::IsNullOrEmpty($PowerShellModuleName)) { $PowerShellModuleName = 'ExchangeOnlineManagement' }$ModuleIsActive = Get-Module -Name $PowerShellModuleName |
Run the following commands to locate the installed PowerShell modules :
Code Block |
---|
|
$Found$ModuleIsInstalled = Get-Module -Name $PowerShellModuleName -ListAvailable |
...
Code Block |
---|
|
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:
...
If ($ModuleIsInstalled) { Update-Module -Name $PowerShellModuleName |
...
To update the module:
...
...
} Else { Install-Module -Name $PowerShellModuleName } |