Managing certificates in Exchange 2010
If you are familiar with Exchange 2010 and trying to install Exchange 2010 for the first time you should have already noticed that the powershell cmdlets used to request and install certificates in Exchange 2007 no longer work in Exchange 2010.
For instance running
New-ExchangeCertificate -GenerateRequest -domainname mail.contoso.msft,autodiscover.contoso.msft,myserver,myserver.internal.contoso.msft -FriendlyName mail.contoso.msft -privatekeyexportable:$true -path c:\cert_myserver.txt
will fail with the following error
A positional parameter cannot be found that accepts argument ‘-Path’.
+ CategoryInfo : InvalidArgument: (:) [New-ExchangeCertificate], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,New-ExchangeCertificate
and running
Import-ExchangeCertificate -path "c:\CertNew.cer"
will also fail with the same error
A positional parameter cannot be found that accepts argument '-path'.
+ CategoryInfo : InvalidArgument: (:) [Import-ExchangeCertificate], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Import-ExchangeCertificate
So here are the commands you should use for Exchange 2010
To request a certificate
$Data = New-ExchangeCertificate –GenerateRequest -domainname mail.contoso.msft,autodiscover.contoso.msft,myserver,myserver.internal.contoso.msft -FriendlyName mail.contoso.msft -privatekeyexportable:$true Set-Content -path "C:\MyCertRequest.req" -Value $Data
To import a .cer certificate
Import-ExchangeCertificate -FileData ([Byte[]]$(Get-Content -Path c:\CertNew.cer -Encoding byte -ReadCount 0))
To import a .crt certificate
Import-ExchangeCertificate -FileData ([Byte[]]$(Get-Content -Path c:\Certfile.crt -Encoding byte -ReadCount 0))
To import a .pfx certificate
Import-ExchangeCertificate -FileData ([Byte[]]$(Get-Content -Path c:\CertwithPriv.pfx -Encoding byte -ReadCount 0)) -Password:(Get-Credential).password
N.B.: you will be prompted for a username/password you can put anything in the user name just don't keep it blank. The password, however, should match the password of the .pfx file.
To import .p7b certificate
Import-ExchangeCertificate -FileData ([Byte[]]$(Get-Content -Path c:\IssuedCert.p7b -Encoding byte -ReadCount 0))
To enable the certificate
This has not changed from Exchange 2007, get first the certificate thumbprint by issuing
get-ExchangeCertificateThen enable it by running
Enable-ExchangeCertificate thumbprintCopied -Services "IIS,POP,IMAP"
Enjoyed the post, what is next?
Grab our FULL RSS feed! or Email Updates then share it
-
Elie M.
-
Antoine Khater

