2012-04-03 31 views
-1

我寫了一個powershell腳本併發送給我的隊友。如何在64位機器上執行powershell腳本?

我的一個隊友,當他右鍵單擊和[與powershell運行]執行腳本,它不工作。

他說這是Win7 64位機器。

然後我手動打開32位Powershell並使用「Powershell -file <Filename>」並執行。

在64位環境下,我們不能簡單地通過右鍵單擊並運行powershell?

+0

你的腳本使用comobject? – 2012-04-03 10:56:19

+0

@Christian:我正在使用PowerCLI snapin。這是我的第一行「Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue」。我應用了你的答案,但仍然失敗。當我右鍵單擊並運行powershell它消失。 (如果我運行在Powershell_ise,它只是說失敗) – Samselvaprabu 2012-04-03 12:07:24

+0

在控制檯中運行的命令'Add-PSSnapin VMware.VimAutomation.Core'工作? – 2012-04-03 12:21:36

回答

4

如果由於某種原因,你的腳本只能運行在x86架構在啓動腳本中的補充一點:

if ($env:Processor_Architecture -ne "x86") 
{ 
     write-warning "Running PowerShell x86" 
     &"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe" -noninteractive -noprofile -file $myinvocation.Mycommand.path -executionpolicy bypass 
     exit 
} 
+0

http://stackoverflow.com/questions/4647429/powershell-on-windows-7-set-executionpolicy-for-regular-users實際問題與鏈接中提到的一樣。它解決了我的問題。 – Samselvaprabu 2012-04-10 07:07:33

相關問題