HAS_CA
Summary
Description
Identification
PowerShell
function Find-HAS_CA {
[CmdletBinding()]
param ([string]$ComputerDistinguishedName = $null,[string]$OutputPath = ".\HAS_CA.csv" )
# 1) Load ActiveDirectory module
Import-Module ActiveDirectory -ErrorAction Stop
# 2) Get Configuration Naming Context
try {
$configurationNC = (Get-ADRootDSE).ConfigurationNamingContext
}
catch {
Write-Error "Failed to retrieve ConfigurationNamingContext: $($_.Exception.Message)"
return
}
# 3) Query all Certificate Authority objects
try {
$caObjects = Get-ADObject -SearchBase $configurationNC -LDAPFilter "(objectClass=pKIEnrollmentService)" -Properties dNSHostName
}
catch {
Write-Error "Failed to query CA objects: $($_.Exception.Message)"
return
}
# 4) Filter by specific computer if provided
if ($ComputerDistinguishedName) {
try {
$dNSHostName = (Get-ADComputer -Identity $ComputerDistinguishedName -Properties dNSHostName).dNSHostName
$caObjects = $caObjects | Where-Object { $_.dNSHostName -eq $dNSHostName }
}
catch {
Write-Error "Failed to match CA to specified computer: $($_.Exception.Message)"
return
}
}
# 5) Format results
$formattedResults = $caObjects | Select-Object Name, dNSHostName
# 6) Export results if found
if ($formattedResults -or $formattedResults.Count -gt 0) {
try {
$formattedResults | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8 -ErrorAction Stop
Write-Host "Results exported to '$OutputPath'"
}
catch {Write-Error "Failed to export to CSV: $($_.Exception.Message)"}
}
else {Write-Output "No HAS_CA entries found."}
}Active Directory Service Interfaces (GUI)
Exploitation
Mitigation
Detection
Event ID
Description
Fields/Attributes
References
References
Last updated
Was this helpful?