Request to certificate with powershell?

2024-08-27T15:24:55.12+00:00

Hi. I have AD CS. Is it possible to request a template certificate using Powershell from https://domain.com/certsrv/certrqma.asp ?

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Rich Matheisen 48,121 Reputation points
2024-08-29T19:22:54.22+00:00

It's been a very long time since I've used *nix!

Here's something cobbled together from bits and pieces found elsewhere:

# create a CSR
openssl req -new -newkey rsa:2048 -nodes -keyout mykey.key -out mycsr.csr

# submit the CSR to the Microsoft CA
curl -k -X POST -H "Content-Type: application/x-www-form-urlencoded" \
-d "Mode=newreq&CertRequest=$(cat mycsr.csr)&CertAttrib=CertificateTemplate:WebServer&TargetStoreFlags=0&SaveCert=yes&ThumbPrint=" \
https://your-ca-server/certsrv/certfnsh.asp

# get the certificate
curl -k -X GET "https://your-ca-server/certsrv/certnew.cer?ReqID=<RequestID>&Enc=b64" -o mycert.cer

# Install the cert
openssl x509 -in mycert.cer -out mycert.pem -outform PEM

I'm not at all sure about ASP support anymore.

Be VERY sure about the security of the URL!!!! The very last thing you want is to expose that URL to unauthorized users. Issuing certs that are valid in your organization to individuals (or machines) over which you have no control would be disastrous.

You may find better information in a forum for your version of Linux. You should probably be using the "Windows Server Security" (not Windows Server Powershell) in any further questions in Microsofts' Q&A forums.

Was this answer helpful?

2 additional answers

Sort by: Most helpful
  1. Hari devaraj 0 Reputation points
    2025-09-07T07:29:43.5733333+00:00

    Export-Certificate -Cert $Certificate -FilePath "C:$certname.cer" $Certificate=Get-ChildItem –Path <Certificate path> Export-Certificate -Cert $Certificate -FilePath "C:\Users\admin\Desktop$certname.cer" Get-ChildItem -Path cert:\CurrentUser\my | Export-Certificate -FilePath c:\certs\allcerts.sst $Pwd = ConvertTo-SecureString -String "Testing" -Force -AsPlainText

    Export-PfxCertificate -Cert $Certificate -FilePath "D:$certname.pfx" -Password $Pwd

    Was this answer helpful?

  2. Rich Matheisen 48,121 Reputation points
    2024-08-27T18:32:11.14+00:00

    Use the Get-Certificate cmdlet.

    You might be able to use the Request-Certificate script, too: (https://www.powershellgallery.com/packages/Request-Certificate/1.5.0)

    Was this answer helpful?