Install a PowerShell module in offline mode

The following example describes the installation of the nupkg SQL Server module offline.

Follow these steps to install a PowerShell module on a Windows server without any internet connection or Microsoft Gallery access.

  1. From a server connected to the internet and with access to the Microsoft Gallery, open the command prompt to install the NuGet provider.
    1. Run the Install-PackageProvider NuGet -MinimumVersion 2.8.5.206 -Force command.
    2. After installation, you can find the provider under C:\Program Files\PackageManagement\ProviderAssemblies.
  2. Copy the NuGet folder to an external media or find a way to get it onto your target system with no internet access.
  3. Copy the NuGet folder on your target computer under C:\Program Files\PackageManagement\ProviderAssemblies.
  4. Start a new PowerShell session on the target computer to auto-load the package provider.
  5. Create a new folder for the nupkg packages' local source location. For example, C:\Packages.
  6. Copy your nupkg files into C:\Packages.
  7. In PowerShell, run the Register-PSRepository -Name Local -SourceLocation C:\Packages -InstallationPolicy Trusted command to register your new local source location.
  8. You can run the Find-Module -Repository Local command to list the available packages.
  9. Run the Install-Module -Name <YourModuleName> -Repository Local -scope allusers -verbose command, where <YourModuleName> is the name of your package returned by the command in step 8. For example, Install-Module -Name SqlServer -Repository Local -scope allusers -verbose.
  10. The installation is done. ✅