Last active
April 26, 2024 09:24
-
-
Save ronascentes/c2419f78be8239d12bf73e8af9f8d982 to your computer and use it in GitHub Desktop.
Install SqlServer Powershell module to a machine without access to PowerShell Gallery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Work perfectly! Thanks!
Nice, thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Work perfectly! Thanks!