Add multiple certificates in MDT task sequence

Rick 41 Reputation points
2024-11-15T13:47:38.84+00:00

I am using a deployment task sequence to call a Powershell script to install multiple certificates, but it is not installing them.

I am using the following in the Power Shell Script:

Import-Certificate -FilePath "%DeploymentRoot%\Scripts\certs\cert1.cer" -CertStoreLocation Cert:LocalMachine\My

Import-Certificate -FilePath "%DeploymentRoot%\Scripts\certs\cert2.cer" -CertStoreLocation Cert:LocalMachine\My

Import-Certificate -FilePath "%DeploymentRoot%\Scripts\certs\cert3.cer" -CertStoreLocation Cert:LocalMachine\My

I tested changing to the full path and installs fine on the server.

I tested the following in the PS script, but doesn't seem to work eventhough if I run the same code while in the last stages of the imaging processs does work.

Set-ExecutionPolicy Unrestricted 

z: 

cd Scripts\certs 

Import-Certificate -FilePath "cert1.cer" -CertStoreLocation Cert:LocalMachine\My

I searched the logs in folder C:\windows\temp\Deployment\Logs, but I don't see any filename for that Task Sequence. I did set the task to "Continue on Error".

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Configuration Manager | Deployment
Windows for business | Windows Server | User experience | Other
{count} votes

1 answer

Sort by: Most helpful
  1. XinGuo-MSFT 22,231 Reputation points
    2024-11-18T01:59:21.1966667+00:00

    Hi,

    Running scripts in the system user context can sometimes lead to issues.

    Use tools like PsExec to test running your script as the system account. This can help you identify any issues that might occur when the script runs in the system context:

    PsExec.exe -s -i PowerShell.exe -File "C:\Path\To\YourScript.ps1"
    

    This approach can help you troubleshoot and ensure that your script works as expected when run in the system context. If you encounter any specific errors or issues, feel free to share them for further assistance.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.