Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Looks like there were some PS enhancements in SQL 2008 SP 2. Are you running that yet? Perhaps this article will help also - 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
add comment

1 Answer

up vote 1 down vote accepted

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/

share|improve this answer
    
A bit of an old one, but relevant if anyone else comes across it –  Chao Dec 30 '11 at 15:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.