Good reference here: https://copdips.com/2018/05/setting-up-powershell-gallery-and-nuget-gallery-for-powershell.html
Here can you see your current clients to gather scripts, modules and packages
Get-PackageProvider
and you will get something like
PS C:\Users\Florian> Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
MyNuGet NuGet False https://www.nuget.org/api/v2
Nuget NuGet False http://www.nuget.org/api/v2
LocalRepo PowerShellGet False C:\Users\Florian\Downloads\20220920
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
Add NuGet to you repositories, if not done yet. You can choose to add a -trusted
flag to the command if you trust any package in that repository
Register-PackageSource -Name Nuget -Location "https://www.nuget.org/api/v2" –ProviderName Nuget
And check if this was successful
Get-PackageSource
Then you can install your scripts. To avoid dependency loops, load all packages first, then make them unique by name and version and install them like here
$pkg = Find-Package npgsql -IncludeDependencies -Verbose
$pkg | Select Name, Version -Unique | % { Install-Package -Name $_.Name -Scope CurrentUser -Source NuGet -Verbose -RequiredVersion $_.Version -SkipDependencies }
To use it, find out the installation location of the package with `Get-Package Npgsql" and load the needed dll version corresponding to your dll version like:
[System.Reflection.Assembly]::LoadFrom("C:\Users\Florian\AppData\Local\PackageManagement\NuGet\Packages\Npgsql.6.0.7\lib\net6.0\Npgsql.dll")
Then open the connection to the database: