Posted On January 30, 2023

How to Install PowerShell Module on An Offlined Computer

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> How to Install PowerShell Module on An Offlined Computer
# Download the desired module onto a 'jump host' (an intermediary computer that has access to the Internet)
PS C:\WINDOWS\system32> Save-Module -Name SqlServer -Path C:\Temp
PS C:\WINDOWS\system32> ls C:\temp
    Directory: C:\temp
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         1/30/2023   5:04 PM                SqlServer

# Add files into remote computer from the jump host
robocopy c:\temp\sqlserver \\SERVERNAME\C$\Program Files\WindowsPowerShell\Modules /E /NP

PS C:\Windows\system32> Enter-PSSession SERVERNAME
[SERVERNAME]: PS C:\Users\kimconnect\Documents> Get-Module -Name SQLServer -ListAvailable
    Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     21.1.18256 SqlServer                           {Add-RoleMember, Add-SqlAvailabilityDatabase, Add-SqlAvail...

# Check SqlServer module's path
[SERVERNAME]: PS C:\Users\kimconnect\Documents> (Get-Module -ListAvailable SQLServer).path
C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.1.18256\SqlServer.psd1

# Import sqlserver powershell module into current session
[SERVERNAME]: PS C:\Users\kimconnect\Documents> Import-Module -Name SqlServer

[SERVERNAME]: PS C:\Users\kimconnect\Documents> get-module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     21.1.18256 SqlServer                           {Add-RoleMember, Add-SqlAvailabilityDatabase, Add-SqlAvail...

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: How to Replace a System File – For Experimentation Purposes

# When attempting to rename a system protected file such as notepad.exe $notepadExe='C:\Windows\system32\notepad.exe' $newNotePadExe='C:\Users\rambo\Desktop\notepad.exe' rename-item…

Find Empty Directories

$directories="\\FILESERVER01\SHARE01" # Dynamic Credential method 1 $who = whoami if ($who.substring($who.length-2, 2) -eq "-admin"){$username=$who;} else…

PowerShell: Trigger Azure AD Sync on Remote Server as a Domain Admin

# Trigger-AD-Sync.ps1# Requirements: https://blog.kimconnect.com/powershell-install-rsat/## This script does these things:# a. Obtain Domain Admin credential# b.…