question

sdoubleday avatar image
sdoubleday asked

PowerShell versions in SQL Server Agent 2008 R2 - How to upgrade from V1.0 to higher versions

I have question about using PowerShell in SQL Server Agent on SQL Server 2008 R2. * What circumstances would lead to only having PowerShell V1.0 available in SQL Server Agent task steps (even when launching PowerShell.exe from a cmdexec step), and how can I get more advanced versions? Googling has revealed to me that the sqlps "mini-shell" used by the PowerShell steps in SQL Agent typically returns a version of 2, but is very constrained in terms of the cmdlets actually available to it. Therefore, it is common to launch new PowerShell.exe processes to get access to either v2.0 or v3.0 functionality. However, when I schedule steps that launch PowerShell in SQL Agent, the shell appears to be version 1. I am beginning to suspect that this server only HAS version 1 installed (originally, I was mislead by launching the SQLPS shell from within SSMS on my workstation and finding version 3.0 available when I would launch PowerShell.exe within the sqlps console - I am reasonably sure that process was launched from my workstation, not whatever is available server side). Working through this question, I think the answer might be that I need to talk to the sysadmin about updating either the operating system (I think that version number indicates the OS is Windows Server 2003) or install PowerShell V3.0 (or maybe both). Does anyone have any cautionary tales about upgrading PowerShell and SQL Agent? Do we need to uninstall PowerShell V1.0? Will SQL Server Agent be able to pick up the new version of PowerShell without trouble? Addendum - Version info: From a PowerShell script run in SQL Agent, using an operating system task (CMDEXEC), which launched powershell.exe and returned $Host.Version information: Major Minor Build Revision ----- ----- ----- -------- 1 0 0 0 The server version: SELECT @@Version Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64) Jun 28 2012 08:36:30 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) (Hypervisor)
sql-server-2008-r2sql-agentpowershellwindows-server-2003
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
It's largely a question of following the [install process][1] for any given version of Powershell to get the server up to date. [1]: http://technet.microsoft.com/en-us/library/hh847837.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.