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.
- From a server connected to the internet and with access to the Microsoft Gallery, open the command prompt to install the NuGet provider.
- Run the Install-PackageProvider NuGet -MinimumVersion 2.8.5.206 -Force command.
- After installation, you can find the provider under C:\Program Files\PackageManagement\ProviderAssemblies.
- Copy the NuGet folder to an external media or find a way to get it onto your target system with no internet access.
- Copy the NuGet folder on your target computer under C:\Program Files\PackageManagement\ProviderAssemblies.
- Start a new PowerShell session on the target computer to auto-load the package provider.
- Create a new folder for the nupkg packages' local source location. For example, C:\Packages.
- Copy your nupkg files into C:\Packages.
- In PowerShell, run the Register-PSRepository -Name Local -SourceLocation C:\Packages -InstallationPolicy Trusted command to register your new local source location.
- You can run the Find-Module -Repository Local command to list the available packages.
- 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.
- The installation is done. ✅