0

I'm trying to install a certificate using cmd on a remote machine. Before you suggest PS please keep in mind I can't use PS since the remote machine is some custom Windows which doesn't have it.
So for everything I am doing remotely I use psexec.

I made a bat file which will use certutil to add certificates to designated stores but I am unsure on how to copy them there push them to store and then remove the files after that. One think to note is that for the remote machine I am logging into I need to use a local account.

Does anyone here have any suggestions?

UrosT
  • 181
  • 1
  • 6

1 Answers1

0

You could transmit the certificates as base64 encoded text over the command line:

REM Convert binary to base64
certutil.exe -encode -f ".\certificate.cer" ".\tmp.b64"

REM Read base64 into variable
SET BASE64CERT=type .\tmp.b64

REM Run commands on remote computer
psexec.exe \\REMOTECOMPUTER "echo %BASE64CERT%> 'c:\Windows\temp\certificate.cer' && certutil.exe -addstore -f 'MY' 'c:\Windows\temp\certificate.cer' ** del 'c:\Windows\temp\certificate.cer'
Daniel Fisher lennybacon
  • 3,865
  • 1
  • 30
  • 38