I am trying to install pfx file automatically every time the Azure Pipeline runs, because with interactive process agent the files seems to loose the password or its just unable to import. Below is the powershell script i am trying to implement with not much success. I need to provide the password automatically:
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")
When the I run the script, i am getting below error:
Start-Process : This command cannot be run due to the error: The system cannot find the file specified. At C:\PowerShellScript\CertReInstall.ps1:12 char:1 + Start-Process -FilePath "sn.exe" -ArgumentList "-i $path $Container ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
I though of using "Import-PfxCertificate" but it does not seem to have option for providing the container name for the install.
Any help would be greatly appreciated. Thank you!
$path
variable. You should check if$path
has a correct value. – Theo