azureautomation / runbooks

Sample Automation runbooks
MIT License
154 stars 129 forks source link

Error in Get-AutomationCertificate for PowerShell 7.2 #100

Open canturan opened 1 year ago

canturan commented 1 year ago

The Get-AutomationCertificate command does not work in PowerShell 7.2 runtime.

The same command works without any problem in PowerShell 5.1. Addition to that, it was also working for the PowerShell 7.2 10 days ago. It is a new bug in the 7.2 runtime. The 7.2 runtime somehow does not have access to the automation account certificates.

The error message: Object not found.

That means, we don't have any possibility to use certificates with the PowerShell 7.2 runtime. I would be very happy, if there would be fix for that as soon as possible.

Thank you!!

canturan commented 1 year ago

I have dug a little bit deeper into the problem. The problem occurs only on the certificates with the private key. If I try to load a certificate, from a file or from a base64 encoded string, I can create the X509 Certificate object without any problem. Only on the certificates with private key (.pfx oder base64 encoded string of a .pfx), I get the same error message "Object not found". That should also be the cause of the problem, when we try to get the Automation Certificate which is also a .pfx (certificate with a private key.) I think it is failing internally during the creation of the X509 object.