Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

New-SelfSignedCertificate

New-SelfSignedCertificate

microsoft.certificateservices.pkiclient.cmdlets.dll

Synopsis

Creates a new self-signed certificate for testing purposes.

Syntax

New-SelfSignedCertificate [-CertStoreLocation] [-CloneCert] [-DnsName] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

The New-SelfSignedCertificate cmdlet creates a self-signed certificate for testing purposes. Using the CloneCert parameter, a test certificate can be created based on an existing certificate with all settings copied from the original certificate except for the public key. A new key of the same algorithm and length will be created.

If an existing certificate is not being cloned, then an SSL server certificate with the following default settings is created: -- Subject: Empty -- Key: RSA 2048 -- EKUs: Client Authentication and Server Authentication -- Key Usage: Digital Signature, Key Encipherment (a0) -- Validity Period: One year

Delegation may be required when using this cmdlet with Windows PowerShell remoting and changing user configuration.

Parameters

-CertStoreLocation <String>

Specifies the certificate store in which a new certificate will be stored. The current path is the default value.

Aliases

None

Required?

false

Position

named

Default value

.

Accept pipeline input?

false

Accept wildcard characters?

false

-CloneCert <Certificate>

Identifies the certificate to copy when creating a new certificate. The certificate being cloned can be identified by an X509 certificate or the file path in the certificate provider. When this parameter is used, all fields and extensions of the certificate will be inherited except the public key (a new key of the same algorithm and length will be created) and the NotAfter and NotBefore fields (the validity period for the NotBefore field is set to ten minutes in the past).

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-DnsName <String>

Specifies one or more DNS names to put into the Subject Alternative Name extension of the certificate when a certificate to be copied is not specified via the CloneCert parameter. The first DNS name is also saved as Subject Name and Issuer Name.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

Microsoft.CertificateServices.Commands.Certificate

Return Type

System.Security.Cryptography.X509Certificates.X509Certificate2

Notes

None

Examples

EXAMPLE 1

This example creates a self-signed SSL server certificate in the computer MY store with the Subject Alternative Name set to www.fabrikam.com, www.contoso.com and Subject and Issuer name set to www.fabrikam.com.

PS C:\> New-SelfSignedCertificate -DnsName www.fabrikam.com, www.contoso.com -CertStoreLocation cert:\LocalMachine\My

EXAMPLE 2

This example creates a copy of the certificate specified by the CloneCert parameter and puts it in the computer MY store.

PS C:\> Set-Location -Path cert:\LocalMachine\My
PS C:\> $copyOf = (Get-ChildItem -Path E42DBC3B3F2771990A9B3E35D0C3C422779DACD7)
PS C:\> New-SelfSignedCertificate -CloneCert $copyOf

Online Version
Get-ChildItem
Set-Location