Skip to content

Commit c47b95a

Browse files
author
Jake Hildreth
committed
Fresh build after merges.
1 parent 7951bfb commit c47b95a

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

Invoke-Locksmith.ps1

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,8 @@ function Find-ESC7 {
15691569
)
15701570
process {
15711571
$ADCSObjects | Where-Object {
1572-
($_.objectClass -eq 'pKIEnrollmentService') -and
1573-
( ($_.CAAdministrator -notmatch 'Failure|CA Unavailable') -or ($_.CertificateManager) )
1572+
($_.objectClass -eq 'pKIEnrollmentService') -and $_.CAHostDistinguishedName -and
1573+
( ($_.CAAdministrator) -or ($_.CertificateManager) )
15741574
} | ForEach-Object {
15751575
$UnsafeCAAdministrators = Write-Output $_.CAAdministrator -PipelineVariable admin | ForEach-Object {
15761576
$SID = Convert-IdentityReferenceToSid -Object $admin
@@ -1613,7 +1613,7 @@ Reinstate CA Administrator rights for $($UnsafeCAAdministrators -join ', ')
16131613
}
16141614
if ($UnsafeCertificateManagers) {
16151615
$Issue.Issue = $Issue.Issue + @"
1616-
Unexpected principals are granted "Certificate Manager" rights on this Certification Authority.
1616+
expected principals are granted "Certificate Manager" rights on this Certification Authority.
16171617
Unexpected Principals: $($UnsafeCertificateManagers -join ', ')
16181618
16191619
"@
@@ -2044,12 +2044,22 @@ function Get-CAHostObject {
20442044
process {
20452045
if ($Credential) {
20462046
$ADCSObjects | Where-Object objectClass -Match 'pKIEnrollmentService' | ForEach-Object {
2047-
Get-ADObject $_.CAHostDistinguishedName -Properties * -Server $ForestGC -Credential $Credential
2047+
if ($_.CAHostDistinguishedName) {
2048+
Get-ADObject $_.CAHostDistinguishedName -Properties * -Server $ForestGC -Credential $Credential
2049+
}
2050+
else {
2051+
Write-Warning "Get-CAHostObject: Unable to get information from $($_.DisplayName)"
2052+
}
20482053
}
20492054
}
20502055
else {
20512056
$ADCSObjects | Where-Object objectClass -Match 'pKIEnrollmentService' | ForEach-Object {
2052-
Get-ADObject $_.CAHostDistinguishedName -Properties * -Server $ForestGC
2057+
if ($_.CAHostDistinguishedName) {
2058+
Get-ADObject -Identity $_.CAHostDistinguishedName -Properties * -Server $ForestGC
2059+
}
2060+
else {
2061+
Write-Warning "Get-CAHostObject: Unable to get information from $($_.DisplayName)"
2062+
}
20532063
}
20542064
}
20552065
}

Private/Find-ESC7.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
}
6565
if ($UnsafeCAAdministrators) {
6666
$Issue.Issue = $Issue.Issue + @"
67-
Unexpected prinicipals ($($UnsafeCAAdministrators -join ', ')) are granted "CA Administrator" rights on this Certification Authority.
67+
Unexpected principals are granted "CA Administrator" rights on this Certification Authority.
68+
Unsafe CA Administrators: $($UnsafeCAAdministrators -join ', ').
6869
6970
"@
7071
$Issue.Fix = $Issue.Fix + @"
@@ -78,15 +79,16 @@ Reinstate CA Administrator rights for $($UnsafeCAAdministrators -join ', ')
7879
}
7980
if ($UnsafeCertificateManagers) {
8081
$Issue.Issue = $Issue.Issue + @"
81-
Unexpected prinicipals ($($UnsafeCertificateManagers -join ', ')) are granted "Certificate Manager" rights on this Certification Authority.
82+
expected principals are granted "Certificate Manager" rights on this Certification Authority.
83+
Unexpected Principals: $($UnsafeCertificateManagers -join ', ')
8284
8385
"@
8486
$Issue.Fix = $Issue.Fix + @"
85-
Revoke CA Administrator rights from $($UnsafeCertificateManagers -join ', ')
87+
Revoke Certificate Manager rights from $($UnsafeCertificateManagers -join ', ')
8688
8789
"@
8890
$Issue.Revert = $Issue.Revert + @"
89-
Reinstate CA Administrator rights for $($UnsafeCertificateManagers -join ', ')
91+
Reinstate Certificate Manager rights for $($UnsafeCertificateManagers -join ', ')
9092
9193
"@
9294
}

0 commit comments

Comments
 (0)