Skip to content

Commit aad1736

Browse files
committed
feat: instead of "deploy", can now "install" and "uninstall"
1 parent 3750cb8 commit aad1736

4 files changed

Lines changed: 129 additions & 8 deletions

File tree

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Deploy-AdcsGoat {
1+
function Install-ADCSGoat {
22
[CmdletBinding()]
33
param (
44
[switch]$Randomize
@@ -49,29 +49,28 @@ function Deploy-AdcsGoat {
4949
# What: Get the list of all Enrollment Services, generate their full CA names, then add the name to the CA object
5050
# Why:
5151
$EnrollmentServices = Find-AGEnrollmentService
52-
$EnrollmentServicesWithFullName = $EnrollmentServices | Set-AGEnrollmentServiceFullName
52+
$EnrollmentServices | Set-AGEnrollmentServiceFullName
5353

5454
# What: Enable ESC5 configuration on all CAs.
5555
# Why:
56-
$EnrollmentServicesWithFullName | ForEach-Object {
56+
$EnrollmentServices | ForEach-Object {
5757
Write-Verbose "Granting Authenticated Users Full Control of: $($_.FullName)"
5858
# Enable-PCEditFlag -CAFullName $_.FullName -Flag EDITF_ATTRIBUTESUBJECTALTNAME2
5959
}
6060

6161
# What: Enable ESC6 configuration on all CAs.
6262
# Why:
63-
$EnrollmentServicesWithFullName | ForEach-Object {
63+
$EnrollmentServices | ForEach-Object {
6464
Write-Verbose "Assigning ESC6 configuration to: $($_.Name)"
6565
Enable-PCEditFlag -CAFullName $_.FullName -Flag EDITF_ATTRIBUTESUBJECTALTNAME2
6666
}
6767

6868
# What: Enable ESC11 configuration on all CAs.
6969
# Why:
70-
$EnrollmentServicesWithFullName | ForEach-Object {
70+
$EnrollmentServices | ForEach-Object {
7171
Write-Verbose "Assigning ESC11 configuration to: $($_.Name)"
7272
Disable-PCInterfaceFlag -CAFullName $_.FullName -Flag IF_ENFORCEENCRYPTICERTREQUEST
7373
}
7474

7575
#endregion ca issues
7676
}
77-
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
function Uninstall-ADCSGoat {
2+
[CmdletBinding()]
3+
param (
4+
[switch]$Randomize
5+
)
6+
7+
#region remove templates
8+
# Load the S.DS
9+
Add-Type -AssemblyName System.DirectoryServices
10+
11+
# Get the Configuration partition automatically via RootDSE
12+
$RootDSE = New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE")
13+
$ConfigurationPartition = $rootDSE.configurationNamingContext
14+
$TemplatesContainer = "CN=Certificate Templates,CN=Public Key Services,CN=Services,$ConfigurationPartition"
15+
$TemplatePath = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$TemplatesContainer")
16+
$AGTemplates = $TemplatePath.Children | Where-Object description -Like '*Generated by ADCSGoat*'
17+
18+
# Delete each ADCSGoat template
19+
foreach ($template in $AGTemplates) {
20+
try {
21+
Write-Verbose "Attempting to delete template: $($template.Name)"
22+
$template.DeleteTree()
23+
Write-Verbose "Successfully deleted template: $($template.Name)"
24+
} catch {
25+
Write-Error "Failed to delete template $($Template.Name): $($_.Exception.Message)"
26+
}
27+
}
28+
29+
# Clean up and dispose of the DirectoryEntry objects
30+
$TemplatePath.Dispose()
31+
32+
#endregion remove issues
33+
34+
#region ca issues
35+
# What: Get the list of all Enrollment Services, generate their full CA names, then add the name to the CA object
36+
# Why:
37+
$EnrollmentServices = Find-AGEnrollmentService
38+
$EnrollmentServices | Set-AGEnrollmentServiceFullName
39+
40+
# What: Disable ESC5 configuration on all CAs.
41+
# Why:
42+
# $EnrollmentServices | ForEach-Object {
43+
# Write-Verbose "Granting Authenticated Users Full Control of: $($_.FullName)"
44+
# Enable-PCEditFlag -CAFullName $_.FullName -Flag EDITF_ATTRIBUTESUBJECTALTNAME2
45+
# }
46+
47+
# What: Disable ESC6 configuration on all CAs.
48+
# Why:
49+
$EnrollmentServices | ForEach-Object {
50+
Write-Verbose "Assigning ESC6 configuration to: $($_.Name)"
51+
Disable-PCEditFlag -CAFullName $_.FullName -Flag EDITF_ATTRIBUTESUBJECTALTNAME2
52+
}
53+
54+
# What: Disable ESC11 configuration on all CAs.
55+
# Why:
56+
$EnrollmentServices | ForEach-Object {
57+
Write-Verbose "Assigning ESC11 configuration to: $($_.Name)"
58+
Enable-PCInterfaceFlag -CAFullName $_.FullName -Flag IF_ENFORCEENCRYPTICERTREQUEST
59+
}
60+
61+
#endregion ca issues
62+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ online version:
55
schema: 2.0.0
66
---
77

8-
# Deploy-AdcsGoat
8+
# Install-ADCSGoat
99

1010
## SYNOPSIS
1111
{{ Fill in the Synopsis }}
1212

1313
## SYNTAX
1414

1515
```
16-
Deploy-AdcsGoat [-Randomize] [<CommonParameters>]
16+
Install-ADCSGoat [-Randomize] [<CommonParameters>]
1717
```
1818

1919
## DESCRIPTION

docs/en-US/Uninstall-ADCSGoat.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
external help file: ADCSGoat-help.xml
3+
Module Name: ADCSGoat
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Uninstall-ADCSGoat
9+
10+
## SYNOPSIS
11+
{{ Fill in the Synopsis }}
12+
13+
## SYNTAX
14+
15+
```
16+
Uninstall-ADCSGoat [-Randomize] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
{{ Fill in the Description }}
21+
22+
## EXAMPLES
23+
24+
### Example 1
25+
```powershell
26+
PS C:\> {{ Add example code here }}
27+
```
28+
29+
{{ Add example description here }}
30+
31+
## PARAMETERS
32+
33+
### -Randomize
34+
{{ Fill Randomize Description }}
35+
36+
```yaml
37+
Type: SwitchParameter
38+
Parameter Sets: (All)
39+
Aliases:
40+
41+
Required: False
42+
Position: Named
43+
Default value: None
44+
Accept pipeline input: False
45+
Accept wildcard characters: False
46+
```
47+
48+
### CommonParameters
49+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
50+
51+
## INPUTS
52+
53+
### None
54+
55+
## OUTPUTS
56+
57+
### System.Object
58+
## NOTES
59+
60+
## RELATED LINKS

0 commit comments

Comments
 (0)