SQLPS (SQL Server 2012)

  • I am starting to learn (work) with PowerShell. On my work laptop I have installed SQL Server 2012 DE. Also using PowerShell 3.0 at the OS level. On our Windows Server 2008 systems we have installed PowerShell 4.0. The version of SQL Server installed on these servers is SQL Server 2008 R2 SE.

    Here is the question.

    Can I install the SQLPS module and supporting files from SQL Server 2012 on the Windows Server 2008 systems and use them at the OS level (PowerShell 4.0) to access work with our SQL Server 2008 R2 instances?

    If I can, is there any thing I need to do to make it work? I have been searching to internet for answers and not finding much that really seems helpful. Some of seems to contradict itself at times.

    At this time everything we are currently writing in PowerShell is external of SQL Server. I am not sure if we will be implementing anything in PowerShell inside of SQL Server.

  • Lynn Pettis (8/3/2014)


    Can I install the SQLPS module and supporting files from SQL Server 2012 on the Windows Server 2008 systems and use them at the OS level (PowerShell 4.0) to access work with our SQL Server 2008 R2 instances?

    Yep, that's exactly what I do. You should only need them on machines you're executing PS from.

    If I can, is there any thing I need to do to make it work? I have been searching to internet for answers and not finding much that really seems helpful. Some of seems to contradict itself at times.

    It doesn't help that there's 2 distinct things called SQLPS out there!

    I add an import-module command to my Powershell profile, otherwise you'll need to load SQLPS manually every time you need it.

    Edit: You might also need to add the module path to the PSModulePath OS environmental variable, but should work regardless if you give the full path to Import-Module

  • Oh, and check your execution setting with Get-ExecutionPolicy if you're running scripts - the default is Restricted which doesn't allow scripts to be executed, including any you've written yourself (you'll get an error message to that effect if you try).

    You can change it using Set-ExecutionPolicy, usually to RemoteSigned but obviously choose whatever's most suitable for your environment.

    Cheers

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply