Reputation: 12988
I am trying to make a very simple script in powershell to create a Certificate using makecert.exe tool (I know powershell already has its own certificate creation method but I would like to use makecert).
I would like to reproduce this command:
makecert.exe -sk server -sky exchange -pe -n CN=<machineName> -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My <certificate path>
How is it possible in powershell?
Upvotes: 0
Views: 206
Reputation: 202032
If you're on V3 or higher, you should consider using the Stop Parsing operator --%. In this way you can specify parameters just like you would in cmd.exe:
makecert.exe --% -sk server -sky exchange -pe -n CN=acme.com -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My C:\test.cer
Although, now that I look at this, it would probably work just fine like this:
makecert.exe -sk server -sky exchange -pe -n CN=acme.com -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My C:\test.cer
I don't see any characters($,@,(,;) that would cause problems for PowerShell. Passing through of quotes can also be a problem but I don't see any quoting in this case.
Upvotes: 3
Reputation: 1772
For most executables, you want to pass the arguments as an array including the switches. Here is an example:
$arguments = "$env:windir\", 'c:\jpegs\','*.jpg', '/R:0', '/S', '/XD', '*winsxs*'
Robocopy.exe $arguments
Upvotes: 4