powershelladfs2.0

How can I remove an ADFS Relying Party Trust Encryption Certificate via PowerShell?


I can add an encryption certificate to an ADFS Relying Party Trust with the following PowerShell command:

Set-ADFSRelyingPartyTrust -TargetName "My RP" -EncryptionCertificate $myCert

I can change the certificate using that same command with a different variable for the EncryptionCertificate parameter, but how can I remove the certificate? Not passing a variable, passing null or the empty string '' results in an exception:

Missing an argument for parameter 'EncryptionCertificate'. 
Specify a parameter of type 'System.Security.Cryptography.X509Certificates.X509Certificate2' 
and try again.

How can I "clear" the certificate that is in place?


Solution

  • You almost had it. In order to remove the encryption certificate from an existing relying party, you have to use the $null variable:

    Set-ADFSRelyingPartyTrust -TargetName "My RP" -EncryptionCertificate $null