Home Forums Programming Powershell Connecting to remote server using powershell subtype RE: Connecting to remote server using powershell subtype

  • Are you using SQL Server 2008 or 2008 R2?

    Powershell steps on 2008/R2 only run at Powershell 1.0 or 2.0 (and only a subset at that!), Enter-PSSession may not be available to it.

    If you've got Powershell 3.0+ installed on the server, a workaround is to create a Command Line step in SQL Agent & execute the ps1 script via Powershell.exe, as you mention you've already done successfully.

    On the other hand, if you're using Invoke-Command then Enter-PSSession might not even be needed.

    Edit:

    Enter-PSSession is used for interactive commands, New-PSSession and Remove-PSSession could be more appropriate for scripts, but still might not be required.

    http://blogs.technet.com/b/heyscriptingguy/archive/2009/10/29/hey-scripting-guy-october-29-2009.aspx

    Cheers

    Gaz