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 Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,289 questions
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Deployment: The process of delivering, assembling, and maintaining a particular version of a software system at a site.
999 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,634 questions
{count} votes

1 answer

Sort by: Most helpful
  1. XinGuo-MSFT 18,921 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.