Powershell – Install modules on Windows Server without internet connection

You are here:
  • Main
  • Powershell - Install modules on Windows Server without internet connection

If you are running a powershell script that requires a specific module to be installed but you’re on a server that is not connected to the internet, here’s how you do it. I’m using the example of the module ‘SqlServer’ but this applies to any Powershell module.

Step by step

Internet Server = The server with internet connection
No Internet Server = The server without internet connection where you want to install the module/package

Step 1 of 9

On the Internet Server, run the following command:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

This makes sure that you’re using TLS1.2 which is required for installing certain modules.

Step 2 of 9

On the Internet Server, run the following command:
Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force

This will make sure the NuGet package provider is installed which is also required for several modules to be installed.

Step 3 of 9

You have now installed the NuGet provider in the folder C:\Program Files\PackageManagement\ProviderAssemblies\NuGet. Copy this NuGet folder from On the Internet Server to the No Internet Server, placing it in the same folder you copied it from.

Step 4 of 9

On the No Internet Server, run the following command to verify that the NuGet provider is installed:
Get-PackageProvider -ListAvailable

If this fails, try running the TLS1.2 setup from step 1 and run again. This should show something like this:

Step 5 of 9

On the Internet Server, in the same Powershell session, run the following command:
Install-Module -Name SqlServer -AllowClobber

If you closed the session between this step and step 1, you need to run the TLS1.2 command in step 1 first and then run the above command.

Step 6 of 9

On the Internet Server, find the installation path of the module by running the following command.
(Get-Module -ListAvailable SQLServer*).path

Take note of the path where this is saved, you will need it in the next step.

Step 7 of 9

On the Internet Server, run the following command:
Save-Module SQLServer -Path "C:\MyPath"

Make sure the folder is created before you run the command. This will create a folder called C:\MyPath\SqlServer. Copy this folder from ServerA to ServerB, placing the folder in the same location as the original module was installed. In this example, we copy the folder SqlServer and place it in C:\Program Files\WindowsPowerShell\Modules\.

Step 8 of 9

On the No Internet Server, run the following command:
Import-Module SQLServer

Step 9 of 9

On the No Internet Server, verify that the module was installed by running the following command:
Get-Module SQLServer

References used

https://docs.microsoft.com/en-us/powershell/module/packagemanagement/install-packageprovider?view=powershell-6

https://www.systemcenterautomation.com/2018/03/installing-powershell-modules-on/

×