以下是我一直在使用1.7.2流浪漢,Ruby和PowerShell中的問題,但是我認爲這是使用PowerShell版本中的一個普遍問題。PowerShell不識別模塊
當我從Cmd的或Poweshell控制檯或ISE運行此命令時,它的工作原理
powershell -version 4.0 -command {import-module C:\windows\system32\windowspowershell\v1.0\Modules\SmbShare\SmbShare.psd1}
當我運行紅寶石IRB裏面如下它也可以
system('powershell -version 4.0 -noprofile -file PsTest.ps1')
然而,當我跑了在使用紅寶石的Vagrant內
-version : The term '-version' is not recognized as the name of a cmdlet, function, script file, or operable program
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
如果我拿出-version參數,我得到
import-module : The specified module 'C:\windows\system32\windowspowershell\v1.0\Modules\SmbShare\SmbShare.
psd1'
我認爲是它試圖使用PowerShell 1.0,但是從劇本中我使用$PSVersionTable
而這一切情況下,我在我包括
(get-process -id $pid).Path
#In all cases (even the one that fails) it returns
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
腳本得到了相同的
Key : PSVersion
Value : 4.0
Key : WSManStackVersion
Value : 3.0
Key : SerializationVersion
Value : 1.1.0.1
Key : CLRVersion
Value : 4.0.30319.42000
Key : BuildVersion
Value : 6.3.9600.17400
Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0}
Key : PSRemotingProtocolVersion
Value : 2.2
而且
不知道什麼是執行不允許從3.0版本開始加載模塊之間的不同,這就是我想這是運行PowerShell 1.0中雖然PSVersionTable清楚地表明它是4.0
只注意到了同樣的事情發生時,我在Visual Studio 2013更新4項目
任何想法,使用相同的腳本作爲預生成事件?
'C:\ WINDOWS \ SYSTEM32 \ windowspowershell \ v1.0'是* *所有版本的PowerShell安裝的主目錄,不要讓'v1.0'文件夾名稱欺騙您。 –
正如你所說的使用(get-process -id $ pid).Path我看到所有的PowerShell的執行指向C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe – jleyva
你能告訴我們適當的片段VagrantFile?去年,我加入了對Vagrant的提供者的shell爭論的支持。請參閱:https://github.com/mitchellh/vagrant/pull/4548 – Eris