What is the difference in the way I launch powershell console?

China☆狼群 提交于 2019-12-11 00:53:02

问题


I work with Sharepoint and I need Sharepoint snap-in present in my console host. When I run powershell from my Windows start menu, I run command

Add-PSSnapin Microsoft.Sharepoint.Powershell

snap-in is added ok, and everything works well.

Also, everything is ok, when I run cmd.exe, and type powershell.exe to it and press enter. So I think no shortcut parameters are involved in this problem (but I not 100% sure :) ).

But when I launch powershell through some launcher (I've tested Launchy and Enso) and I try to add the same snap-in, it fails with this error message:

Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At somefile.ps1:7 char:14
+     Add-PSSnapin <<<<  Microsoft.Sharepoint.Powershell
+ CategoryInfo          : InvalidArgument:(Microsoft.Sharepoint.Powershell:String)     
[Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : 
AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

What is the difference when I launch powershell with launcher?

I think this is not sharepoint related problem but rather powershell one.

(note: I know about Sharepoint management shell and question is not about it)


回答1:


No sure 100% but you may have a trouble with PowerShell 32 bits versus PowerShell 64 Bits.

For Example if your SnapIn is 64 bits, it can be only use with PowerShell 64 bits. If Launchy and Enso are 32 bits they starts powerShell 32 bits that look for a 32 bits SnapIn. It's the same thing in the other side.

From a 64 bits process, you can force using PowerShell 64 bits using :

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe

From a 64 bits process, you can force using PowerShell 32 bits using :

c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe

From a 32 bits process, you can force using PowerShell 64 bits using (Read this):

c:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe


来源:https://stackoverflow.com/questions/10788040/what-is-the-difference-in-the-way-i-launch-powershell-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!