Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • 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 2012
    • 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)

January 10, 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

Using Previous Command History in PowerShell Console

January 31, 2023

How to Install the PowerShell Active Directory Module...

January 31, 2023

Enable Internet Explorer (IE) Compatibility Mode in Microsoft...

January 27, 2023

Finding Duplicate E-mail (SMTP) Addresses in Exchange

January 27, 2023

How to Disable or Uninstall Internet Explorer (IE)...

January 26, 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

  • Using Previous Command History in PowerShell Console

    January 31, 2023
  • How to Install the PowerShell Active Directory Module and Manage AD?

    January 31, 2023
  • Finding Duplicate E-mail (SMTP) Addresses in Exchange

    January 27, 2023
  • How to Delete Old User Profiles in Windows?

    January 25, 2023
  • How to Install Free VMware Hypervisor (ESXi)?

    January 24, 2023
  • How to Enable TLS 1.2 on Windows?

    January 18, 2023
  • Allow or Prevent Non-Admin Users from Reboot/Shutdown Windows

    January 17, 2023
  • Fix: Can’t Extend Volume in Windows

    January 12, 2023
  • Wi-Fi (Internet) Disconnects After Sleep or Hibernation on Windows 10/11

    January 11, 2023
  • Adding Trusted Root Certificates on Linux

    January 9, 2023

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Configuring Port Forwarding in Windows
  • Installing RSAT Administration Tools on Windows 10 and 11
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • How to Hide Installed Programs in Windows 10 and 11?
  • Adding Drivers into VMWare ESXi Installation Image
Footer Logo

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


Back To Top