Powershell: Install a nupkg module offline


the powershell gallery offers a lot of modules for online installation. It’s also possible to download a nupkg file of that module and install it offline.

In this example I will install the powershell-yaml module

Firts of all download the nupkg package. The nupkg is a zip file.

PS D:\temp> Invoke-WebRequest -UseBasicParsing -Uri https://psg-prod-eastus.azureedge.net/packages/powershell-yaml.0.4.2.nupkg  -OutFile powershell-yaml.0.4.2.zip
PS D:\temp> Expand-Archive powershell-yaml.0.4.2.zip -DestinationPath powershell-yaml

Importend: The Destination Path must have the same basename as the *.psd1 and the *.psm1 within the expanded folder.

Then you can import the module by the path where the module is expanded to.

PS D:\temp> Import-Module -Name D:\Temp\powershell-yaml
PS D:\Temp> get-command -Module powershell-yaml

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        ConvertFrom-Yaml                                   0.4.2      powershell-yaml
Function        ConvertTo-Yaml                                     0.4.2      powershell-yaml

Or copy the folder powershell-yaml to one of the default module pathes where the powershell searches for modules when calling Import-Module.

PS D:\temp> $ENV:PSModulePath.Split(";") 
C:\Program Files\WindowsPowerShell\Modules

PS D:\temp> Copy-Item -Recurse D:\temp\powershell-yaml "C:\Program Files\WindowsPowerShell\Modules"


Advertisment to support michlstechblog.info

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.