Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / Installing PowerShell Modules in Offline Mode (Without Internet Access)

March 15, 2024 PowerShellWindows 10Windows Server 2019

Installing PowerShell Modules in Offline Mode (Without Internet Access)

Most popular PowerShell modules are installed online from the official PowerShell Gallery (PSGallery) repository using the Install-Module command. However, you won’t be able to install a PowerShell module if your computer is in an isolated network or direct access to PSRepository is restricted. The same is true when you are trying to install the PowerShell module on Windows Server hosts, which usually have direct Internet access blocked. In this article, we’ll show how to install PowerShell modules offline and to import a module from a remote computer (for example, when using the SQLServer management PoSh module).

Contents:
  • How to Install PowerShell Modules on Offline Computers?
  • Import PowerShell Module from a Remote Computer

Note that there are no direct links to download modules from PowershellGallery.com. The only thing you can download from the site is the NuGet package (a .nupkg file). You can install a PowerShell module from the NUPKG file, but this will not be a complete module installation (the main problem is that the dependencies are not resolved).

install powershell module from powershellgallery offline using nupkg file

How to Install PowerShell Modules on Offline Computers?

First of all, install the PowerShell module you need on a computer with Internet access.

PowerShell version 5.1 or newer must be installed on the computer:

$PSVersionTable.PSVersion

Make sure that the module exists in PSGallery:

Find-Module –Name *SqlServer*| Select Name, Version, Repository

Find-Module in powershell gallery

Download the module to the specified local folder on your computer:

Save-Module –Name SqlServer –Path C:\PS\

Save-Module: download powershell module to local folder

Copy the folder to another computer you want to install the module on.

Let’s see what folders PowerShell modules are stored in:

$env:PSModulePath -split ";"

Where the PowerShell Modules are stored?

As you can see, PowerShell modules are located on one of the following paths:

  • C:\Users\username\Documents\WindowsPowerShell\Modules ($Home\Documents\PowerShell\Modules) – PowerShell modules in this folder are available only to this user (CurrentUser);
  • C:\Program Files\WindowsPowerShell\Modules ($Env:ProgramFiles\WindowsPowerShell\Modules) — the path is used to install a module for all computer users (-Scope AllUsers);
  • C:\Windows\system32\WindowsPowerShell\v1.0\Modules – default folder for built-in modules.

Copy the module to C:\Program Files\WindowsPowerShell\Modules.

copy powershell module files to offline computer

Make sure that the SQLServer module is now available:

Get-Module -Name SQLServer -ListAvailable

Get-Module installed

You can get the module directory as shown below:

(Get-Module -ListAvailable SQLServer).path

get powershell module path

Display the list of commands available in the module:

Get-Command -Module SQLServer

In the same way, you can install any module. I often use this method to install SQLServer, PSWindowsUpdate, or PowerCLI for VMware modules.

Import PowerShell Module from a Remote Computer

If you don’t want to install a PowerShell module on all computers, you can import any module from a remote computer using PSRemoting:

$session = New-PSSession -ComputerName dub-sql1

To display a list of modules installed on a remote computer:

Get-Module -PSSession $session –ListAvailable

To import the specified PowerShell module to your computer:

Import-Module -PSsession $session -Name SqlServer

Don’t forget to close the session when you finish:

Remove-PSSession $session

Another interesting way to locally use a PowerShell module installed on a remote computer via Implicit remoting.

Connect to a remote computer using the Invoke-Command and import the PowerShell module you want:
$session = New-PSSession -ComputerName dub-sql1
Invoke-Command {Import-Module SqlServer} -Session $session

Export module cmdlets from the remote session to the local module:

Export-PSSession -Session $s -CommandName *-Sql* -OutputModule RemoteSQLServer -AllowClobber

The command creates a new RemoteSQLServer PowerShell module on your computer (in C:\Program Files\WindowsPowerShell\Modules). The cmdlet files themselves are not copied.

Close the session:

Remove-PSSession $session

Then to use PowerShell cmdlets from this module, you just need to import them into the session:

Import-Module RemoteSQLServer

All SQL module cmdlets will be available without establishing an explicit connection to the remote computer. Try to query the MS SQL database using the Invoke-Sqlcmd command. All MSSQL commands are available until you close your PowerShell console or remove the module.

1 comment
5
Facebook Twitter Google + Pinterest
previous post
Blank Sign-in Screen in Office 365 Apps (Outlook, Teams, etc.)
next post
How to Extend Office 2021/2019/2016 & Office 365 Trial Period

Related Reading

View Windows Update History with PowerShell (CMD)

April 30, 2025

Change BIOS from Legacy to UEFI without Reinstalling...

April 21, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Allowing Ping (ICMP Echo) Responses in Windows Firewall

April 15, 2025

How to Pause (Delay) Update Installation on Windows...

April 11, 2025

1 comment

Daniel Verberne April 11, 2022 - 1:15 pm

Bravo. Excellent blog. Clear, concise and thorough instructions that leave me the viewer in no doubt that you know your stuff. I’ve read a number of guides on the topic of offline (or isolated) computers and installing PowerShell Modules, but I know this one is the best. I’m copying this link like no one’s business. Thanks very much for taking the time to document this!

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • Fix: Remote Desktop Licensing Mode is not Configured
  • How to Delete Old User Profiles in Windows
  • Configuring Port Forwarding in Windows
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top