Skip to content

Instantly share code, notes, and snippets.

@xabim
Created June 6, 2018 10:29
Show Gist options
  • Save xabim/577a8c9b8408288ed46ff431b029d8be to your computer and use it in GitHub Desktop.
Save xabim/577a8c9b8408288ed46ff431b029d8be to your computer and use it in GitHub Desktop.
Certificate Request with exportable
Write-Host "Creating CertificateRequest(CSR) for $CertName `r "
Invoke-Command -ComputerName testbox -ScriptBlock {
$CertName = "Script Automation"
$CSRPath = "c:\temp\$($CertName)_.csr"
$INFPath = "c:\temp\$($CertName)_.inf"
$Signature = '$Windows NT$'
$INF =
@"
[Version]
Signature= "$Signature"
[NewRequest]
Subject = "CN=$CertName, O=Contoso, L=Boston, S=Massachusetts, C=US"
KeySpec = 1
KeyLength = 2048
Exportable = TRUE
MachineKeySet = TRUE
SMIME = False
PrivateKeyArchive = FALSE
UserProtected = FALSE
UseExistingKeySet = FALSE
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
RequestType = PKCS10
KeyUsage = 0xa0
[EnhancedKeyUsageExtension]
OID=1.3.6.1.4.1.311.80.1
"@
write-Host "Certificate Request is being generated `r "
$INF | out-file -filepath $INFPath -force
certreq -new $INFPath $CSRPath
}
write-output "Certificate Request has been generated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment