无法启动SQL Server PowerShell

你们有没有这个问题,当你从SQL Server启动PowerShell的时候,会抛出一个像下面这样的exception?

无法parsing别名'cd',因为它引用了术语'Microsoft.PowerShell.Managment \ Set-Location',它不被识别为cmdlet,函数,可操作的程序文件或脚本文件。 validation术语,然后重试。 在行:1 char:140 +&[[System.Console] :: Title ='SQL Server Powershell'; Convert-UrnToPath'Server [@Name =''AIMLESS''] / Database [@Name =''AdventureWorks2008' ']'| cd <<<<}

我无法用pwdcd等一些常见的别名进行导航。即使get-alias清除,显示cdset-locationpwdget-location

替代文字

[更新]别名也不能设置 替代文字

我很确定我在几个月前遇到过,但在快速search后再也找不到它了。 我相信用户的GAC一些如何被损坏/混淆。

你能够启动一个常规的PowerShell会话吗?

你如何更新.NET版本?

您是否使用PowerShell社区扩展? 不幸的是,他们使用默认的profile.ps1文件而不是Microsoft.PowerShell_profile.ps1。 如果是这种情况,您只需将您的Profile.ps1重命名为Microsoft.PowerShell_profile.ps1即可。 SQLPS不会加载Microsoft.PowerShell_profile.ps1configuration文件只有主机不可知configuration文件profile.ps1。 这里有工作项目

http://www.codeplex.com/Pscx/WorkItem/View.aspx?WorkItemId=18417

这绝对听起来像一个configuration文件问题给我。 我find了一篇文章(a),讲述了一次安装的Powershell版本1testing版引起的类似问题。

我会查看configuration文件链中的每个文件,以查看哪个文件重映射到您的别名。 然后,您可以重命名configuration文件来testing是否是问题。 我不太确定你是如何启动Powershell的,但是如果SQL Server启动Powershell,你会想看看它的用户帐户的configuration文件。

这应该做到这一点…

 notepad '$env:windir\system32\WindowsPowerShell\v1.0\profile.ps1' notepad '$env:windir\system32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1' notepad '$env:UserProfile\My Documents\WindowsPowerShell\profile.ps1' notepad '$env:UserProfile\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1' 

(a)Profile.msh可能的错误:

如果加载profile.msh文件,并且以前安装了Monad的早期版本,则在启动时可能会看到一系列错误,如:

set-alias:AllScope选项不能从别名“cat”中删除。 在C:\ Documents and Settings \ All Users \ Documents \ msh \ profile.msh:9 char:10 + set-alias <<<< cat get-content

要解决这个问题,要么删除名为(在本例中为“C:\ Documents and Settings \ All Users \ Documents \ msh \ profile.msh”)的文件,要么删除所有的“set-alias”行。 在早期版本的Monad中,profile.msh中定义的别名现在由Monad在内部定义,在configuration文件运行之前; 因此,profile.msh中的定义将尝试重新定义别名时会生成一个错误。

http://www.latenighthacking.com/archives/reference/PowerShellDocumentationPack_rc1/Windows%20PowerShell%20RC1%20release%20notes.htm