38 lines
911 B
PowerShell
38 lines
911 B
PowerShell
[CmdletBinding()]
|
|
param (
|
|
[Parameter(Mandatory)]
|
|
[string]$DomainName
|
|
)
|
|
$CertName = "$DomainName"
|
|
|
|
Write-Host "Creating CertificateRequest(CSR) for $CertName"
|
|
|
|
$CSRPath = "$($CertName)_.csr"
|
|
$INFPath = "$($CertName)_.inf"
|
|
$Signature = '$Windows NT$'
|
|
$INF =
|
|
@"
|
|
[Version]
|
|
Signature= "$Signature"
|
|
[NewRequest]
|
|
Subject = "CN=$CertName, L=Brisbane, S=QLD, C=AU"
|
|
KeySpec = 1
|
|
KeyLength = 4096
|
|
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.5.5.7.3.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"
|
|
Get-Content "$($CertName)_.csr" |