2016-09-21 53 views
0

在「可信設備」文件夾中安裝.cer證書我需要證書安裝到名爲.cer「可信設備」文件夾,因爲我有PowerShell腳本自動安裝軟件和唯一的事情就是阻止孔腳本,詢問窗口關於加密狗司機的值得信賴。通過PowerShell的

我用裏面流浪

vagrant.exe powershell -c "Import-Certificate -Filepath C:\vagrant\Microcosm.cer -CertStoreLocation Cert:\Local Computer\TrustedDevices" 

此cmdlet下面是錯誤消息輸出

vagrant.exe : The following WinRM command responded with a non-zero exit status. 
At line:1 char:2 
+ vagrant.exe powershell -c "Import-Certificate -Filepath C:\vagrant\Microcosm.ce ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   : NotSpecified: (The following W...ro exit status.:String) [], RemoteException 
+ FullyQualifiedErrorId : NativeCommandError 

Vagrant assumes that this means the command failed! 
Import-Certificate -Filepath C:\vagrant\Microcosm.cer -CertStoreLocation Cert:\Local Computer\TrustedDevices 
Stdout from the command: 
Stderr from the command: 
#< CLIXML 
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">Import-Certificate : A positional parameter cannot be found that accepts argument 'Computer\Trust 
edDevices'._x000D__x000A_</S><S S="Error">At line:1 char:40_x000D__x000A_</S><S S="Error">+ ... lyContinue';Import-Certificate -Filepath C:\vagrant\Microcosm.cer -Ce ..._x000D__x000A_</S><S 
S="Error">+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error"> + CategoryInfo   : InvalidArgument: (:) [Import-Certificate], P 
arameterBindingException_x000D__x000A_</S><S S="Error"> + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.CertificateServices.Commands.ImportCertificateComm _x000D__x000A_</ 
S><S S="Error"> and_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs> 

回答

0

證書:\本地計算機\ TrustedDevices有一個空間在裏面。嘗試使用您的路徑中的轉義引號:

vagrant.exe powershell -c "Import-Certificate -Filepath C:\vagrant\Microcosm.cer -CertStoreLocation `"Cert:\Local Computer\TrustedDevices`"" 
+0

謝謝,BenH。當我執行命令時出現問題 vagrant.exe:未找到名稱爲「Computer \ TrustedDevices」的計算機配置爲 在行:1個字符:1 + vagrant.exe powershell -c「導入證書-FilePath C:\流浪漢\ Microcosm.cer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :(機器wit ...配置爲:String)[],RemoteException + FullyQualifiedErrorId:NativeCommandError –