Switch-Certificate
Switch-Certificate
Marks one certificate as having been replaced by another certificate.
Syntax
Parameter Set: Default
Switch-Certificate [-OldCert] <Certificate> [-NewCert] <Certificate> [-NotifyOnly] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Switch-Certificate cmdlet marks one certificate as having been replaced by another certificate. This cmdlet triggers a replace certificate notification and optionally sets the renewal property on the certificate being replaced.
Parameters
-NewCert<Certificate>
Specifies an X509 certificate or a certificate path for the certificate that replaces the certificate specified with the OldCert parameter.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-NotifyOnly
Creates a replacement certificate notification without replacing the NewCert parameter with the OldCert parameter. This mode is useful when testing a script that was registered with the New-CertificateNotificationTask cmdlet.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-OldCert<Certificate>
Specifies an X509 certificate or a certificate path in the certificate provider for the certificate to be replaced.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Microsoft.CertificateServices.Commands.Certificate
The Certificate object can either be provided as a Path object to a certificate or an X509Certificate2 object.
Outputs
The output type is the type of the objects that the cmdlet emits.
- None
Examples
EXAMPLE 1
This example sets the renewal property of the certificate with the thumbprint E42DBC3B3F2771990A9B3E35D0C3C422779DACD7 as renewed by the certificate with the thumbprint 4A346B4385F139CA843912D358D765AB8DEE9FD4 and generates a replace certificate notification.
PS C:\> Switch-Certificate –OldCert cert:\LocalMachine\My\E42DBC3B3F2771990A9B3E35D0C3C422779DACD7 –NewCert cert:\LocalMachine\My\4A346B4385F139CA843912D358D765AB8DEE9FD4
EXAMPLE 2
This example locates two certificates in the machine MY store and assigns them the variables $oldCert and $newCert. This cmdlet then generates a replacement notification without changing a renewal property of the old certificate.
PS C:\> Set-Location -Path cert:\LocalMachine\My
PS C:\> $oldCert = (Get-ChildItem -Path E42DBC3B3F2771990A9B3E35D0C3C422779DACD7)
PS C:\> $newCert = (Get-ChildItem -Path 4A346B4385F139CA843912D358D765AB8DEE9FD4)
PS C:\> Switch-Certificate -OldCert $oldCert -NewCert $newCert –NotifyOnly
Related topics
Get-CertificateNotificationTask
New-CertificateNotificationTask