I am trying to create a self-signed certificate with specific encryption settings.
On a Win Server 2012 r2 server running PowerShell 5.0 when I try to use
New-SelfSignedCertificate
I get an error message:
New-SelfSignedCertificate: parameter cannot be found that matches the name of the parameter "Subject".
when I try to use a parameter -Subjectthat, in addition to other parameters allowed on my laptop, does not appear in intellisense.
However, on my laptop (Win 10 and PowerShell 5.0), I am allowed to use these options, and I create a self-signed certificate using the following code
$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
$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