-
1Powershell Setup: Installing Modules and Packages on Windows
(Assumed) Initial State:
- I want to minimize changing of user rights on my machine, so that what I do can be replicated elsewhere.
- Assuming no admin rights, and no write access C:\Program Files and C:\Windows, you can run the following to install modules and packages.
Installing Modules (from PowerShell-Gallery):
To install powershell modules without admin rights, save the module to a custom file path instead of the default one:
Find-Module -Name XXX | Save-Module -Path ".\lib\XXX"
Installing Packages (from Nuget/PackageManagement):
Make sure to register NuGet as a package provider with:
Install−PackageProvider −Name Nuget −Force
Then make sure to register NuGet as a package source with:
Register-PackageSource -provider NuGet -name NuGetGallery -location https://www.nuget.org/api/v2 -trusted
**NOTE: at time of this log, this command invokes the V2 API despite the V3 API being available. Currently, while that is true, the V3 API isn't as widely supported yet, so V2 is still currently the "most stable"
To check your work, run these commands:
Get-PackageProvider; Get-PackageSource;
If you need to unregister a package source, you can do so with:
Unregister-PackageSource -Name XXXX
where XXXX is the name listed from Get-PackageSource.
As far as I currently know, the provider field/property returned from Get-PackageSource should match one of the names from Get-PackageProvider
To install a package:
Find-Package -name XXXX -ProviderName NuGet | \ Install-Package -Destination ".\lib"
Or alternatively, you can use the name of the source to do the install:
Find-Package -name XXXX -Source NuGetGallery | \ Install-Package -Destination ".\lib"
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.