I'm trying to create a self signed certificate with specific encryption parameter values.
On a Win Server 2012 r2 standard running PowerShell 5.0, when I attempt to use
New-SelfSignedCertificate
I receive an error:
New-SelfSignedCertificate : A parameter cannot be found that matches parameter name 'Subject'.
when I attempt to use the -Subject
parameter, which in addition to other parameters allowed on my laptop, does not appear in the intellisense.
However on my laptop (Win 10 and PowerShell 5.0) I'm allowed to use these parameters, and I create a self-signed certificate by using the following code
#create a Certificate
# OID for document encryption
$Oid = New-Object System.Security.Cryptography.Oid "1.3.6.1.4.1.311.80.1"
$oidCollection = New-Object System.Security.Cryptography.OidCollection
$oidCollection.Add($oid) > $Null
# Create enhanced key usage extension that allows document encryption
$Ext = New-Object System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension $oidCollection, $true
$myCert = New-SelfSignedCertificate -Subject 'CN=myservernameasubject' -CertStoreLocation "Cert:\LocalMachine\My" -KeySpec KeyExchange -KeyUsage KeyEncipherment, DataEncipherment -Extension $Ext