获取SQL Server 2008以使用Powershell 2

我有一台运行Windows Server 2008(不是R2)和SQL Server 2008的服务器。我安装了Powershell 2,运行Powershell脚本时工作正常。 但是,当试图在SQL作业中运行Powershell脚本时,它似乎使用Powershell v1运行,因为它返回以下内容:

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

我怎样才能让它运行我的脚本与Powershell V2的?

这是SQL Server 2008和SQL Server 2008 R2中的sqlps minishell的限制。 导入模块或添加快照不支持在一个小型shell中。 如果您对SQL Server minishell实现的详细概述感兴趣,请参阅以下博客文章:

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