Examples/Demo.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
break

Get-Module -ListAvailable
Import-Module ADCSTemplate
Get-Command -Module ADCSTemplate

# Manually open ADSIEDIT and show objects
adsiedit.msc

# Manually open MMC to build and browse an AD CS mgmt GUI
mmc

New-ADCSDrive
cd ADCS:
dir
cd '.\CN=Certificate Templates'
dir
cd ..
cd '.\CN=Enrollment Services'
dir
cd c:

cd \
md ADCS
cd ADCS

Get-ADCSTemplate
Get-ADCSTemplate | Sort-Object DisplayName | ft DisplayName

Export-ADCSTemplate -DisplayName PSCMS
Export-ADCSTemplate -DisplayName PSCMS > PSCMS.json

New-ADCSTemplate -DisplayName PSCMS2 -JSON (Get-Content .\PSCMS.json -Raw) -Publish

Set-ADCSTemplateACL -DisplayName PSCMS2 -Identity 'goatee\domain computers' -Enroll -AutoEnroll
(Get-ADCSTemplate pscms2).nTSecurityDescriptor.Access

Remove-ADCSTemplate -DisplayName pscms2 -WhatIf
Remove-ADCSTemplate -DisplayName pscms2
Remove-ADCSTemplate -DisplayName Tanium