Skip to main content

AD Health Audit - Self Heal

Description

This agnostic powershell script is designed to performs an Active Directory (AD) health audit on a Domain Controller (DC). It checks for common AD issues using tools like dcdiag and repadmin, scans event logs for errors, and optionally performs self-healing actions and restarts critical AD-related services.

Requirements

PowerShell 5.0 + AD Domain Controller

Usage

Domain Controller Check: Ensures the script runs only on a DC. Logging: Creates a timestamped log file in C:\ProgramData_Automation\Script\ADHealthServices. Health Checks: dcdiag /v repadmin /replsummary repadmin /showrepl Event logs: DNS Server and Directory Service Self-Healing (optional): Forces AD replication Flushes and registers DNS Re-registers DC in DNS Service Restart (optional): Restarts services like NTDS, DNS, kdc, Netlogon, W32Time Can restart all or specific services

.\ADHealthAudit_SelfHeal.ps1
.\ADHealthAudit_SelfHeal.ps1 -SelfHeal
.\ADHealthAudit_SelfHeal.ps1 -ServicesToRestart 'Netlogon','W32Time'
.\ADHealthAudit_SelfHeal.ps1 -RestartAllADServices
.\ADHealthAudit_SelfHeal.ps1 -SelfHeal -RestartAllADServices
.\ADHealthAudit_SelfHeal.ps1 -SelfHeal -ServicesToRestart 'DNS','Netlogon'

Parameters

ParameterAliasRequiredDefaultTypeDescription
SelfHealaFalseSwitchIf specified, performs self-healing actions when issues are detected.
ServicesToRestartbFalseStringOptional list of specific services to restart.
RestartAllADServicescFalseSwitchIf specified, restarts all core AD-related services.

Output

  • Script Log
  • Log file: C:\ProgramData_Automation\Script\ADHealthServices.