每次Azure管道运行时,我都会自动安装pfx文件,因为使用交互式处理代理,文件似乎会丢失密码或无法导入。下面是我正在尝试实现的powershell脚本,但没有成功。我需要自动提供密码:
Set-Location "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools"
Start-Process -FilePath "sn.exe" -ArgumentList "-NoExit","-d","$Container"
Start-Process -FilePath "sn.exe" -ArgumentList "-i $path $Container" -NoNewWindow -Wait
[System.Windows.Forms.SendKeys]::SendWait("$password") 当我运行脚本时,我得到的错误如下:
启动进程:由于错误,该命令无法运行:系统找不到指定的文件。在C:\PowerShellScript\CertReInstall.ps1:12 char:1 +Start Process -FilePath "sn.exe“-ArgumentList -i $path $Container .++ CategoryInfo : InvalidOperation:(:) Start-Process,InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,-i
我想使用"Import-PfxCertificate“,但它似乎没有为安装提供容器名称的选项。
任何帮助都将不胜感激。谢谢!
发布于 2019-11-28 15:42:08
经过大量的尝试和错误,最后,我能够找出它有问题的路径。它实际上是在抱怨-FilePath "sn.exe",而不是参数列表中的path。即使Set-Location完成了它的工作,第二个Start-Process也有问题。因此,我更新这一行如下:
Start-Process -FilePath "sn.exe" -ArgumentList "-i $path $Container" -NoNewWindow -Wait这使得文件找不到错误消失。
https://stackoverflow.com/questions/59082032
复制相似问题