1

I have a server running Windows Server 2008 (not R2) and SQL Server 2008. I installed Powershell 2 and it works fine when running Powershell scripts. However when trying to run a Powershell script in a SQL Job it appears to run using Powershell v1 as it returns the following:

A job step received an error at line 1 in a PowerShell script. The corresponding line is 'Import-Module Pscx'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The term 'Import-Module' is not recognized as the name of a cmdlet, function, script file, or operable program

How can I get it to run my scripts with Powershell v2?

Chao
  • 113
  • 4
  • Looks like there were some PS enhancements in SQL 2008 SP 2. Are you running that yet? Perhaps this article will help also - http://max-pit.spaces.live.com/blog/cns!A034D6A0DDC4E64E!821.entry – Christopher Oct 14 '10 at 20:24
  • That does seem to explain the improvements though I have since ended up getting my job to run powershell and call my script rather than have the script itself in the job which seems to work fine, thanks anyway though. – Chao Oct 15 '10 at 14:48

1 Answers1

1

This is a limitation of the sqlps minishell in SQL Server 2008 and SQL Server 2008 R2. Importing modules or adding snappins are not supported in a a minishell. If you're interested in a detailed overview of the SQL Server minishell implementation see this blog post:

http://sev17.com/2010/05/the-truth-about-sqlps-and-powershell-v2/

Chad Miller
  • 1,101
  • 8
  • 11