Last post Apr 11, 2018 02:56 AM by Brando ZWZ
Apr 06, 2018 01:38 PM|JAYHAWKER|LINK
I am trying to automate creating of self-signed certificates, and thus creating a script in PowerShell and using New-SelfSignedCertificate to create the certificates.
Successful creation of a new certificate creates a new thumbprint. I am wanting to grab that thumbprint programmably and put it in a variable to use later.
How do I do that?
Apr 11, 2018 02:56 AM|Brando ZWZ|LINK
According to your description, I suggest you could try to use System.Management.Automation dll to run the powershell script creating the certificate.
Then you could get the result of powershell script output.
More details, you could refer to below codes:
static void Main(string args)
PSDataCollection<PSObject> outputCollection = new PSDataCollection<PSObject>();
PowerShell psinstance = PowerShell.Create();
string Script = @"New-SelfSignedCertificate -DnsName 'www.fabrikam.com', 'www.contoso.com' -CertStoreLocation 'cert:\LocalMachine\My'";
var result = psinstance.BeginInvoke<PSObject, PSObject>(null, outputCollection);
foreach (PSObject outputItem in outputCollection)
//TODO: handle/process the output items if required