{"id":179074,"date":"2022-05-25T12:35:25","date_gmt":"2022-05-25T17:35:25","guid":{"rendered":"https:\/\/itblog.ldlnet.net\/?p=179074"},"modified":"2024-05-10T08:37:34","modified_gmt":"2024-05-10T13:37:34","slug":"step-by-step-process-for-installing-a-new-exchange-server-certificate-using-powershell","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2022\/05\/25\/step-by-step-process-for-installing-a-new-exchange-server-certificate-using-powershell\/","title":{"rendered":"Step-by-Step Process for Installing a New Exchange Server Certificate Using PowerShell"},"content":{"rendered":"\n<p>In Exchange 2016 CU23 and Exchange 2019 CU12, the ability to create and manage certificates via the GUI has been deprecated per this article: <a href=\"https:\/\/itblog.ldlnet.net\/index.php\/2022\/05\/23\/deprecation-of-certificate-tools-in-exchange-admin-center-gui\/\">Deprecation of Certificate Tools in Exchange Admin Center GUI \u2013 IT Blog (ldlnet.net)<\/a>. So, I wanted to show everyone how to now use PowerShell to do the Exchange Certificate Management as it is handled differently than regular PKI cmdlets and tools are used. <\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-align-center\">First installment is to do this for a New Certificate for your Exchange Server and NOT a renewal<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Generate your CSR<\/h4>\n\n\n\n<p>Follow your protocols for setting up your Subject Alternative Name Certificate Domains. I use my UCC SAN Certificate with ADFS as well as Exchange so I have a total of 5 domains listed on my Certificate:<br><br>mail.ldlnet.net &lt;&#8211; Common Name<br>adfs.ldlnet.net &lt;&#8211; SAN for ADFS Services<br>download.ldlnet.net &lt;&#8211; SAN for Exchange Security Protocol<br>autodiscover.ldlnet.net &lt;&#8211;SAN for Exchange AutoDiscover<br>owa.ldlnet.net &lt;&#8211; SAN For Outlook on the Web<\/p>\n\n\n\n<p>You want to have your Identifiers set for your certificate as well:<br>C= (Country)<br>S= (State)<br>L= (Location)<br>O= (Organization Name)<br>OU= (Department Name or Type of Business)<br><br>Make sure it is SHA2 \/ AES256 with 2048 bit Encryption.<br>Have a file folder where to store the request.<\/p>\n\n\n\n<p>This must be done on your Exchange Server running Exchange Management Shell as it will create the private key pair to encrypt your certificate:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Generate CSR via PowerShell\">$txtrequest = New-ExchangeCertificate -GenerateRequest -FriendlyName \"Your SAN Cert\" -SubjectName \"C=US,S=NC,L=Charlotte,O='LDLNET LLC',OU=IT,CN=mail.ldlnet.net\" -DomainName autodiscover.ldlnet.net,download.ldlnet.net,adfs.ldlnet.net,owa.ldlnet.net -KeySize 2048 -PrivateKeyExportable $true  ; [System.IO.File]::WriteAllBytes('\\\\web010.yourserver.com\\C$\\Certs\\LDLNET2023.req', [System.Text.Encoding]::Unicode.GetBytes($txtrequest))<\/pre>\n\n\n\n<p>That should create a CSR file that you will use to upload or copy\/paste to according to your Certificate Provider. It will look something like the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"867\" height=\"718\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-3.png\" alt=\"\" class=\"wp-image-179114\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-3.png 867w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-3-300x248.png 300w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-3-768x636.png 768w\" sizes=\"auto, (max-width: 867px) 100vw, 867px\" \/><figcaption class=\"wp-element-caption\">REQ File<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Complete The CSR Request<\/h4>\n\n\n\n<p>Once you have validated your certificate and downloaded from your provider, you will unzip the certificates and place your .crt file in a directory on the same exchange server you generated the request from. I saved mine to the c:\\root\\ directory.<\/p>\n\n\n\n<p>Next run the following cmdlet to Import the Exchange Certificate and complete the CSR request that you Generated:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Import Exchange Certificate on Generating Exchange Server\">Import-ExchangeCertificate -FileData ([System.IO.File]::ReadAllBytes('\\\\ex2019-01\\c$\\root\\mail.ldlnet.net.crt')) -Password (ConvertTo-SecureString -String 'P@ssw0rd1\" -AsPlainText -Force) -PrivateKeyExportable:$true -Server ex2019-01.yourdomain.com<\/pre>\n\n\n\n<p>If there are no errors, then you should see the certificate with the new thumbprint in the Exchange Certificate List as well as in the Personal Certificate Store of the Certificates MMC Snap-In:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"329\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-4-1024x329.png\" alt=\"\" class=\"wp-image-179390\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-4-1024x329.png 1024w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-4-300x96.png 300w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-4-768x247.png 768w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-4.png 1166w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"228\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-5-1024x228.png\" alt=\"\" class=\"wp-image-179391\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-5-1024x228.png 1024w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-5-300x67.png 300w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-5-768x171.png 768w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-5.png 1441w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Enable Exchange Services to the Certificate<\/h4>\n\n\n\n<p>Next, we need to Enable the certificate to be used for all the services in Exchange. That is done with the following cmdlet:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Enable Exchange Certificate on Generating Exchange Server\">Enable-ExchangeCertificate -Thumbprint <YourImportedCertificateThumbprint> -Services IIS,SMTP,POP,IMAP<\/pre>\n\n\n\n<p>NOTE: Choose Yes to overwrite the existing Default SMTP Certificate and validate the new thumbprint will replace it. Since this is a new installation, this is the proper method.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"161\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-6-1024x161.png\" alt=\"\" class=\"wp-image-179431\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-6-1024x161.png 1024w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-6-300x47.png 300w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-6-768x120.png 768w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2022\/05\/image-6.png 1486w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Enable-Exchange Certificate<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Export the PFX Certificate<\/h4>\n\n\n\n<p>Once that is completed, we will need to export the working certificate to use for our other Exchange Servers so that the Exchange services on those servers use the same certificate. To do this properly, we need to export the certificate as a .pfx (PKCS #12 Personal File Exchange) Certificate. This was why making the Private Key Exportable in the CSR was so important. You need to extract the key pair when exporting the certificate so that you can properly use it on the other Exchange Servers.<\/p>\n\n\n\n<p>The process has TWO lines of commands to export. Remember to choose a directory to save the .pfx to and choose a password that you will remember as you will need it to import on the other servers. The procedure to export our working certificate is as follows:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:True\" title=\"Export Exchange Certificate on Generating Exchange Server\">$cert = Export-ExchangeCertificate -Thumbprint <YourWorkingCertificateThumbprint> -BinaryEncoded -Password (ConvertTo-SecureString -String 'YourPa$$w0rd' -AsPlainText -Force)\n\n[System.IO.File]::WriteAllBytes('C:\\root\\LDLNET2023final.pfx', $cert.FileData)<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Import the PFX to the other Exchange Servers and Install<\/h4>\n\n\n\n<p>Copy the file to the other Exchange Server and run the import procedure. Remember to set the path to the .pfx file, set the Exchange Server you are installing on, and MAKE THE PRIVATE KEY EXPORTABLE, just in case you lose the .pfx file. See example: <\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Import Exchange Certificate on Other Exchange Server \/ .pfx\">Import-ExchangeCertificate -FileData ([System.IO.File]::ReadAllBytes('\\\\ex2019-01\\c$\\root\\LDLNET2023final.pfx')) -Password (ConvertTo-SecureString -String 'YourPa$$w0rd\" -AsPlainText -Force) -PrivateKeyExportable:$true -Server ex2019-other.yourdomain.com<\/pre>\n\n\n\n<p><em>Enable the Exchange Services for the imported certificate the same way as above.<\/em><\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Enable Exchange Certificate on Generating Exchange Server\">Enable-ExchangeCertificate -Thumbprint <YourImportedCertificateThumbprint> -Services IIS,SMTP,POP,IMAP<\/pre>\n\n\n\n<p>You should then be good to go for that Exchange Server!<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\">PING ME WITH QUESTIONS! I WILL UPDATE AS NEEDED!<br>THANKS FOR READING!<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">About Lance Lingerfelt<\/h2>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\" style=\"grid-template-columns:22% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"412\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2024\/03\/ProfLDL1.jpg\" alt=\"Lance Lingerfelt Profile Photo\" class=\"wp-image-196223 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-small-font-size\">Lance Lingerfelt is an M365 Specialist and Evangelist with over 20 years of experience in the Information Technology field. Having worked in enterprise environments to small businesses, he is able to adapt and provide the best IT Training and Consultation possible. With a focus on AI, the M365 Stack, and Healthcare, he continues to give back to the community with training, public speaking events, and this blog.<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In Exchange 2016 CU23 and Exchange 2019 CU12, the ability to create and manage certificates via the GUI has been deprecated per<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2022\/05\/25\/step-by-step-process-for-installing-a-new-exchange-server-certificate-using-powershell\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":877,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2,265,3,266],"tags":[28,27,9,149,151,232,147,29],"class_list":["post-179074","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-general","category-microsoft365","category-powershell","category-security-and-compliance","tag-certificate","tag-certificates","tag-exchange","tag-exchange-2016","tag-exchange-2019","tag-exchange-deployment","tag-exchange-setup","tag-pki","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/179074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=179074"}],"version-history":[{"count":8,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/179074\/revisions"}],"predecessor-version":[{"id":196310,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/179074\/revisions\/196310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/877"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=179074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=179074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=179074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}