-
Notifications
You must be signed in to change notification settings - Fork 0
Get PKIHealthReport
Operational health monitoring script that validates CA infrastructure, distribution points, and service status with automated scoring.
This script provides comprehensive health monitoring of Certificate Authority infrastructure by validating operational status, testing distribution points, analyzing event logs, and generating an overall health score (0-100) with actionable recommendations.
- Service Monitoring - CA service status and responsiveness validation
- Certificate Expiration - CA certificate expiration tracking and alerting
- Database Health - Size metrics, record counts, and statistics
- CRL Validation - Publication status and distribution point accessibility
- AIA Validation - Authority Information Access distribution point testing
- Template Health - Certificate template availability in Active Directory
- Event Log Analysis - Recent Certificate Services errors and warnings
- Health Scoring - Automated 0-100 health rating with issue weighting
- Recommendations - Actionable items based on detected issues
- PowerShell 5.1 or later
- Administrator privileges
- Must be run ON the Certificate Authority server (local execution only)
- Certificate Services running
- Network access to test distribution points (HTTP/HTTPS)
- Firewall exceptions for distribution point URLs
- Event log read permissions
Directory path where reports and CSV exports will be saved.
- Type: String
-
Default:
C:\Reports\PKI_Health -
Example:
-OutputDirectory "D:\PKI_Health"
Verify CRL distribution points are accessible and current.
- Type: Boolean
-
Default:
$true -
Example:
-CheckCRLDistribution $false
Verify AIA (Authority Information Access) distribution points are accessible.
- Type: Boolean
-
Default:
$true -
Example:
-CheckAIADistribution $false
Flag certificates and CRLs expiring within this number of days.
- Type: Integer
- Range: 1-365
- Default: 30 days
-
Example:
-DaysToExpiration 15
Number of hours to review in Application event logs.
- Type: Integer
- Range: 1-168 (1 week)
- Default: 24 hours
-
Example:
-EventLogHours 48
Organization name for report headers.
- Type: String
- Default: "Organization"
-
Example:
-OrganizationName "Contoso"
.\Get-PKIHealthReport.ps1Runs complete health check with default settings - 24 hours of event logs, 30-day expiration threshold.
.\Get-PKIHealthReport.ps1 -DaysToExpiration 15 -EventLogHours 48Flags items expiring within 15 days and reviews 48 hours of event logs.
.\Get-PKIHealthReport.ps1 -OutputDirectory "D:\PKI_Health" -CheckCRLDistribution:$falseRuns assessment with custom output directory, skipping CRL distribution point checks.
.\Get-PKIHealthReport.ps1 `
-OutputDirectory "\\FileServer\PKI\Health" `
-EventLogHours 72 `
-DaysToExpiration 7 `
-OrganizationName "Dendreon"Complete health assessment with UNC output, 72-hour event review, 7-day expiration alerting, and organization branding.
C:\Reports\PKI_Health\
βββ HOSTNAME_PKI_Health_YYYYMMDD_HHMMSS\
βββ HOSTNAME_PKI_CRLHealth_YYYYMMDD_HHMMSS.csv
βββ HOSTNAME_PKI_AIAHealth_YYYYMMDD_HHMMSS.csv
βββ HOSTNAME_PKI_TemplateHealth_YYYYMMDD_HHMMSS.csv
βββ HOSTNAME_PKI_EventLogIssues_YYYYMMDD_HHMMSS.csv
βββ HOSTNAME_PKI_Health_Report_YYYYMMDD_HHMMSS.txt
Distribution point accessibility status.
Columns:
-
URL- CRL distribution point URL -
Accessible- True/False accessibility status -
StatusCode- HTTP status code (200 = success) -
Message- Error message if failed -
TestedAt- Timestamp of test
Authority Information Access point validation.
Columns:
-
URL- AIA distribution point URL -
Accessible- True/False accessibility status -
StatusCode- HTTP status code -
Message- Error message if failed -
TestedAt- Timestamp of test
Certificate template availability in AD.
Columns:
-
TemplateName- Template name -
Status- Available | Not Found | Error -
Published- True if published to CA -
Issue- Description of any problems
Recent Certificate Services errors/warnings.
Columns:
-
TimeCreated- Event timestamp -
Level- Error | Warning -
EventID- Windows event ID -
Message- Event description (truncated to 200 chars) -
Source- CertificationAuthority
Comprehensive health assessment with recommendations.
Sections:
- Overall Health Status (score, status, error/warning counts)
- Certificate Authority Information
- CA Certificate Status (expiration tracking)
- Database Health (size, records, statistics)
- CRL Health (publication status, distribution points)
- AIA Health (distribution point accessibility)
- Certificate Templates (availability status)
- Event Log Analysis (recent errors/warnings)
- Recommendations (actionable items based on findings)
- Exported Files List
- 90-100: EXCELLENT - No significant issues detected
- 70-89: GOOD - Minor warnings present, no critical issues
- 50-69: FAIR - Multiple issues requiring attention
- 0-49: POOR - Critical issues requiring immediate action
- -50: Certificate Services not running (CRITICAL)
- -10: CA certificate expired (CRITICAL)
- -10: CRL overdue for publishing (CRITICAL)
- -5: Error event detected
- -5: Failed CRL distribution point
- -5: Failed AIA distribution point
- -2: Warning event detected
- -2: CA certificate expiring soon
- -2: High pending request count (>100)
- -2: Template availability issue
- -2: Large database size (>10 GB)
- Validates PowerShell version and admin rights
- Checks for Certificate Services (CertSvc)
- Creates output directory with timestamp
- Initializes health score at 100
- Queries local CA configuration
- Retrieves CA certificate expiration
- Tests CA responsiveness with ping
- Calculates days until CA cert expires
- Locates CA database directory
- Calculates database size in MB
- Queries certificate statistics (issued, revoked, pending, failed)
- Warns if database exceeds 10 GB
- Retrieves last CRL publication date
- Calculates time until next CRL publication
- Alerts if CRL is overdue
- Tests HTTP accessibility of CRL URLs (if enabled)
- Times out after 10 seconds per URL
- Extracts AIA URLs from CA certificate
- Tests HTTP accessibility of .crt/.cer URLs (if enabled)
- Records status codes and error messages
- Queries published templates from CA
- Verifies each template exists in Active Directory
- Reports templates published but missing in AD
- Queries Application log for Certificate Services events
- Filters by time range (default 24 hours)
- Captures Error (Level 2) and Warning (Level 3) events
- Truncates messages to 200 characters
- Applies weighted deductions for each issue
- Ensures score doesn't go below 0
- Determines status: EXCELLENT | GOOD | FAIR | POOR
- Generates actionable recommendations
- Creates CSV exports for each health area
- Produces comprehensive text report
- Displays color-coded console summary
Impact: -50 health score (CRITICAL)
Solution:
Start-Service CertSvcImpact: -10 health score (CRITICAL)
Solution: Renew CA certificate immediately - this is a critical outage
Impact: -10 health score (CRITICAL)
Solution:
# Force CRL publication
certutil -CRLImpact: -5 health score per failed URL
Solution:
- Verify web server hosting CRL is running
- Check firewall rules allow HTTP/HTTPS access
- Confirm IIS/Apache configuration
- Test URL from client machine
Impact: -2 health score per template
Solution:
- Verify template exists in AD:
CN=Certificate Templates,CN=Public Key Services... - Unpublish missing templates from CA
- Or restore template to Active Directory
Impact: -2 health score
Solution:
# Archive old certificate records
certutil -databaseclean +3months# Import CRL health data
$crlHealth = Import-Csv "C:\Reports\PKI_Health\*\*_CRLHealth_*.csv"
# Show inaccessible CRLs
$crlHealth | Where-Object { $_.Accessible -eq 'False' } |
Format-Table URL, Message# Get last 5 health reports
$reports = Get-ChildItem "C:\Reports\PKI_Health" -Directory |
Sort-Object Name -Descending |
Select-Object -First 5
foreach ($report in $reports) {
$file = Get-ChildItem $report.FullName -Filter "*_Health_Report_*.txt"
$content = Get-Content $file.FullName -Raw
if ($content -match 'Health Score:\s*(\d+)') {
Write-Host "$($report.Name): Score $($Matches[1])"
}
}# Load event log issues
$events = Import-Csv "C:\Reports\PKI_Health\*\*_EventLogIssues_*.csv"
# Group by Event ID
$events | Group-Object EventID |
Sort-Object Count -Descending |
Format-Table Count, Name# Step 1: Comprehensive assessment
.\Get-ComprehensivePKIReport.ps1 -OrganizationName "Contoso"
# Step 2: Health validation
.\Get-PKIHealthReport.ps1 -OrganizationName "Contoso"
# Step 3: Consolidate if multi-CA
.\Merge-PKIAssessmentReports.ps1# Create scheduled task for weekly health checks
$action = New-ScheduledTaskAction -Execute 'PowerShell.exe' `
-Argument '-File "C:\Scripts\Get-PKIHealthReport.ps1"'
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 6am
Register-ScheduledTask -TaskName "PKI Health Check" `
-Action $action `
-Trigger $trigger `
-RunLevel Highest- Schedule Regular Checks - Weekly health reports catch issues early
- Monitor Health Scores - Investigate any drop below 90
- Test Distribution Points - Ensure CRL/AIA URLs accessible from client networks
- Review Event Logs - Certificate Services errors indicate underlying issues
- Track CA Cert Expiration - Plan CA certificate renewals 90+ days in advance
- Validate Templates - Remove published templates that don't exist in AD
- Archive Database - Keep database size manageable (<10 GB)
- Alert on Critical Issues - Automate notifications for health scores <70
- Administrator Access: Reads CA configuration and event logs
- Network Testing: Performs HTTP requests to distribution points
- Output Protection: Health reports contain infrastructure details
- Event Log Data: May contain sensitive error messages
- Get-ComprehensivePKIReport.ps1 - Deep PKI infrastructure assessment
- Merge-PKIAssessmentReports.ps1 - Multi-CA consolidation
- v1.0 (2025-12-24): Initial release with health monitoring and scoring
- Overview
- Start-LyncCsvExporter
- Get-ComprehensiveLyncReport
- Get-LyncHealthReport
- Get-LyncInfrastructureReport
- Get-LyncServiceStatus
- Get-LyncUserRegistrationReport
- Export-ADLyncTeamsMigrationData
- New-Office365Accounts
- Sync-ContactsFromCsv
- Set-EmailToSharedAccount
- Set-SMTPForward
- Invoke-UserSignOutAndBlock
- Security Assessment Scripts (coming soon)
- Azure Automation (documentation pending)
- Get-GraphToken
- Get-GraphHeaders
- Get-AzureResourcePaging
- Get-EnterpriseAppUsage
- Get-ExchangeErrorsGraph
- Get-PBIWorkspaceUsageReport
- Intune Management (documentation pending)