The ability to find and install PowerShell modules from online sources like Nuget makes life for a Windows admin a smidge nicer. On the flipside, arbitrary trust of online package repositories and granting servers outbound internet access can be a nightmare for those tasked with protecting a network.
You might find yourself needing to install a PowerShell module (as a nupkg file) on a system with restricted (or no) internet access, as one of our security consultants found himself needing to do.
Here’s a quick guide on how to achieve this. If only it were as simple as
Install-PackageProvider -Name NuGet -RequiredVersion 184.108.40.206 -Forceto install the provider from a computer with an internet connection.
Register-PSRepository -Name Local -SourceLocation C:\Packages -InstallationPolicy Trusted
Find-Module -Repository Local
Install-Module -Name <YourModuleName>where
<YourModuleName>is the name of your package as returned by the command in step 8.
I put this together with information from trebleCode and Nova Sys Eng in this StackOverflow thread. Thanks go out to those fine people.