# request模板
$requestInf= @'
;----------------- request.inf -----------------
[Version]
Signature="$Windows NT$"
[NewRequest]
;Change to your,country code, company name and common name
Subject = "C=CN, O=Mosser Lee, CN=www.pstips.net"
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.5.5.7.3.1 ; this is for Server Authentication / Token Signing
;-----------------------------------------------
'@
#输出模板到文件
$requestInfFile = 'request.inf'
$requestCSRFile = 'request.csr'
$requestInf | Out-File $requestInfFile
#创建证书
certreq -new $requestInfFile $requestCSRFile
#打印证书路径
$requestCSRFile = (Get-Item $requestCSRFile).FullName
Write-Host "CSR文件已保存到 $requestCSRFile"