2016-09-21 71 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 –