PowerShell Script to Retrieve and Export Permissions of PKI Templates

49885604 150 Reputation points
2024-02-08T12:11:41.8866667+00:00

Hello everyone, I am looking for some assistance in preparing a PowerShell script that retrieves the permissions of all Public Key Infrastructure (PKI) templates present in ADSI Edit\Services\Public Key Services. The script should export these permissions to a CSV file. I already have a script, but it requires me to set the name of each template manually. I need a more efficient solution that can extract the permissions of all templates without me having to specify each one. Thank you in advance for your help (see file attached). Best regards, Alessio.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,901 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,408 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,504 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,446 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Marius Ene 335 Reputation points
    2024-02-08T18:49:58.95+00:00

    Hi, I don't see the file attached anywhere. You could create a foreach loop that will pass through each template name and call your script using the template name. Here is a sample pseudo-code:

    # Get all PKI template names
    $TemplateNames = Get-ADObject -Filter 'objectClass -eq "pKICertificateTemplate"' -SearchBase "CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=domain,DC=com" | Select-Object -ExpandProperty Name
    foreach($temp in $TemplateNames)
    {
        .\Your-script.ps1 -TemplateName $temp
    }
    

    Good luck! Marius ENE - https://mariusene.com/

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.