KeyAlgorithm for SHA256 KeyAlgorithm for SHA256 powershell powershell

KeyAlgorithm for SHA256


KeyAlgorithm parameter defines the public key algorithm which is not related to signature algorithm (what you are trying to accomplish). Instead, you need to use -HashAlgorithm parameter and specify SHA256 as a parameter value:

New-SelfSignedCertificate -DnsName "MyCertificate", "www.contoso.com" `    -CertStoreLocation "cert:\LocalMachine\My" `    -Provider "Microsoft Strong Cryptographic Provider" `    -HashAlgorithm "SHA256"