Skip to content

Instantly share code, notes, and snippets.

@ronascentes
Last active April 26, 2024 09:24
Show Gist options
  • Save ronascentes/c2419f78be8239d12bf73e8af9f8d982 to your computer and use it in GitHub Desktop.
Save ronascentes/c2419f78be8239d12bf73e8af9f8d982 to your computer and use it in GitHub Desktop.
Install SqlServer Powershell module to a machine without access to PowerShell Gallery
# download the module to local folder
Invoke-WebRequest -Uri powershellgallery.com/api/v2/package/sqlserver -Out C:\temp\sqlserver.zip
# unzip the file
Expand-Archive -LiteralPath 'C:\temp\sqlserver.zip' -DestinationPath C:\temp\sqlserver
# remove powershell gallery related files
Push-Location C:\temp\sqlserver
Remove-Item .\_rels\ -Recurse -Force
Remove-Item .\package\ -Recurse -Force
Remove-Item [Content_Types].xml -Force
Remove-Item *.nuspec -Force
Pop-Location
# copy to psmodule path
Copy-Item C:\temp\sqlserver\* -Destination C:\Program Files\WindowsPowerShell\Modules\sqlserver -Recurse -Force
# Check if Powershell is able to see it:
Get-Module -ListAvailable
# Result expected:
# Directory: C:\Program Files\WindowsPowerShell\Modules
# ModuleType Version PreRelease Name PSEdition ExportedCommands
# ---------- ------- ---------- ---- --------- ----------------
# Script 22.0.59 sqlserver Core,Desk {Add-RoleMember, Add-SqlAvailabilityDat…
# to import SqlServer module
Import-Module SqlServer
@sanketkamdi
Copy link

Work perfectly! Thanks!

@sbhomale
Copy link

Work perfectly! Thanks!

@pcEnte-net
Copy link

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment