Install PowerShell module from PSGallery
Prerequisites
The PowerShellModuleName variable must already be defined or one of the following values must be set:
Install the PowerShell module
Run the following commands to verify the NuGet provider is installed:
Find-PackageProvider -Name 'NuGet' -Force -ForceBootstrapRun the following commands to trust the PSGallery:
Set-PSRepository -Name 'PSGallery' -InstallationPolicy TrustedRun the following commands to locate any installed instance of the PowerShell module
$ModuleIsInstalled = Get-Module -Name $PowerShellModuleName -ListAvailableRun the following commands to locate any active instance of the PowerShell module:
$ModuleIsActive = Get-Module -Name $PowerShellModuleNameRun the following commands to unload any active instance of the PowerShell module
If ($ModuleIsActive) { Remove-Module -Name $PowerShellModuleName -Force }Run the following commands to update or install the latest version of the PowerShell module from the PSGallery:
If ($ModuleIsInstalled) { Update-Module -Name $PowerShellModuleName -Verbose } Else { Install-Module -Name $PowerShellModuleName -Verbose }