Hello, this isn't really an issue per-say, just wanted to post this here in case anyone else has the same issue. I was getting the following error when running the script:
Exception calling "GetSecurityDescriptor" with "0" argument(s): "Unknown error (0x80005000)"
I looked through the code to find the offending line, and it was running Get-AuditCertificateTemplate <ca name>. When I ran the command manually it also errored out with the same message, so it's definitely an issue with the PowerShell module. After some guess and check I found that this error is caused by having a "/" in the certificate template name. After I renamed and deleted any templates with a / it was able to run sucessfully.