How to Use PowerShell to Generate CSR for Exchange 2010
Generating a Certificate Signing Request (CSR) is a key step in securing your server with an SSL certificate. This guide provides two methods to generate a CSR for Exchange 2010 using PowerShell, allowing you to choose between displaying the CSR directly on the screen or saving it to a file.
In this article, we'll cover:
Method 1: Displaying the CSR on Screen
- Open the Exchange Management Shell.
- Run one of the following commands to generate your CSR.
Basic Command:
New-ExchangeCertificate -GenerateRequest -SubjectName 'C=GB, O=Sectigo Limited, cn=owa.sectigo.com' -KeySize 2048 -PrivateKeyExportable $true
Command with Multiple Domain Names (SANs):
Use this command to include Subject Alternative Names (SANs) like `autodiscover`.New-ExchangeCertificate -GenerateRequest -SubjectName 'C=GB, O=Sectigo Limited, cn=owa.sectigo.com' -DomainName owa.sectigo.com, owa, autodiscover.sectigo.com -PrivateKeyExportable $true
- The CSR will be displayed directly in the shell window. You can now copy the entire text block, including the `-----BEGIN NEW CERTIFICATE REQUEST-----` and `-----END NEW CERTIFICATE REQUEST-----` lines, to submit to your certificate provider.
Method 2: Saving the CSR to a File
- Open the Exchange Management Shell.
- Run the following two commands in order.
Step 1: Generate the CSR and store it in a variable.
$CSR = New-ExchangeCertificate -GenerateRequest -SubjectName 'C=GB, O=Sectigo Limited, cn=owa.sectigo.com' -PrivateKeyExportable $true
Step 2: Save the variable's content to a text file.
This command will create a file named `2010certreq.txt` on your C: drive.Set-Content -Path 'C:\2010certreq.txt' -Value $CSR
- Your CSR is now saved to the file path you specified. You can open this file with any text editor to copy its contents.
Review
Using the `New-ExchangeCertificate` cmdlet in PowerShell, you can quickly generate a CSR for your Exchange 2010 server. By following the steps in this guide, you can create the CSR you need to get your SSL certificate issued and properly secure your server.