Install powershell sql server module

Ashwan 536 Reputation points
2020-10-27T06:52:44.167+00:00

hi

I am in the process of refresh SQL Server(2016 SP2) production to test env thruogh the PS screpit and powershell are failing to connect SQL Server using Invoke-Sqlcmd. I cant find the sql server module either

This server has no internet access

Not sure how to install sql server module on the server .

Any one can advice quold be highy appreciated

35244-pscapture.png

35371-pscapture1.png

35255-pscapture2.png

SQL Server Other
{count} votes

3 answers

Sort by: Most helpful
  1. AmeliaGu-MSFT 14,006 Reputation points Microsoft External Staff
    2020-10-27T08:19:37.817+00:00

    Hi @Ashwan ,

    You can try to download the SQL Server module to a file in computer with internet access, and then copy it to the target server which have no internet access.
    For more details, please refer to the following articles:
    How can I install the SQL Server PowerShell module on an offline machine
    INSTALLING POWERSHELL MODULE WITHOUT INTERNET ACCESS

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Vaibhav Chaudhari 38,916 Reputation points Volunteer Moderator
    2020-10-27T08:22:27.41+00:00

    In the first screenshot, at first line, $ sign is missing. Could you make it $SQLServer instead of SQLServer.

    To import module syntax is - Import-Module SqlServer (not import sqlserver module)


    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

    0 comments No comments

  3. Ben Miller (DBAduck) 966 Reputation points
    2020-10-29T03:06:36.383+00:00

    The easiest way is to get on a machine with 5.1 PS installed that has access to the internet and then run

    Install-Module sqlserver
    

    Then when it installs go to C:\Program Files\WindowsPowerShell\Modules\ and copy the folder SqlServer to the server that does not have access to the internet.

    You will need to copy it to the machine in a folder that you have control over (not a protected one like in Program Files) like C:\Temp so now you have C:\Temp\SqlServer.

    Then you will copy from that folder the SqlServer folder to C:\Program Files\WindowsPowerShell\Modules and once you do you can import the module on that server.

    Nowadays the modules are xcopy deployment once you have installed it. You can also use Save-Module to pull the module down and save it in a certain place instead of using Install-Module if that is easier too.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.