Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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

February 28, 2022 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.

For obvious reasons, it doesn’t make sense to install AzureAD and Exchange Online PowerShell modules on offline devices.

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 MS SQL database using Invoke-Sqlcmd. All MSSQL commands are available until you close your PowerShell console or remove the module.

1 comment
1
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

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

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

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

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

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


Back To Top