Create a self-signed certificate with New-SelfSignedCertificate
Windows' built-in certificate authority in one cmdlet — issue test TLS certificates into the machine store for local HTTPS and IIS bindings.
01Command
$ New-SelfSignedCertificate -DnsName dev.local -CertStoreLocation Cert:\LocalMachine\My02What it does
This cmdlet creates a real X.509 certificate with the SAN you specify and drops it straight into the chosen store — no openssl config files needed. The default produces a certificate with modern key usage; add `-NotAfter (Get-Date).AddYears(2)` to control lifetime and `-FriendlyName` to find it later. Browsers will still warn until you copy the certificate into Trusted Root (Cert:\LocalMachine\Root) or bind it in IIS/Kestrel with its thumbprint.
03Risk
04Undo
$ Remove-Item Cert:\LocalMachine\My\<thumbprint>05Sources
- New-SelfSignedCertificate | Microsoft LearnEvidence: Microsoft documents New-SelfSignedCertificate parameters -DnsName and -CertStoreLocation and notes it creates a self-signed test certificate.
Last verified: 2026-09-17 · Category: Security & Privacy
06Related solutions
Read the Authenticode signature status and signer of any executable or script in PowerShell.
Understand PowerShell's execution policy scopes and set the one that lets you run your own local scripts without gutting the security model.
Search inside text files and logs with regex, returning file, line number and match.