Hello all. I am working on trying to be able to automate the installation of mutual authentication certificates to a service account user store for an application that I support. When I try and enter a PSSession on the remote machine as the service account, PowerShell looks like it does it’s thing, but the certificate is never installed.
This is the code I’m trying to run:
PS C:\WINDOWS\system32> Enter-PSSession -ComputerName remotemachine -Credential $cred
[remotemachine]: PS C:\Users\serviceaccount\Documents> Import-PfxCertificate -FilePath C:\temp\mutualauth.pfx -Password (ConvertTo-SecureString “password” -AsPlainText -Force) -CertStoreLocation Cert:\CurrentUser\my
[remotemachine]: PS C:\Users\serviceaccount\Documents>
As you can see, the command completes without error. If I log into the remote machine and run Enter-PSSession -ComputerName localhost-Credential $cred I am able to run that import without any issues.
I have also tried to run it through Invoke-Command -ComputerName remotemachine -Credential $cred -ScriptBlock and get the same result. Any ideas why the certificate fails to import if the .pfx is on the remote machine and the code being invoked is on a remote machine?