# You probably want to run AD Domain Controller hardening checks like this before the attackers do it.
# Query Active Directory for Domain Controllers
$domainControllers = Get-ADDomainController -Filter *
foreach ($dc in $domainControllers) {
$dcName =
$dc.HostName
Write-Host "Checking Domain Controller:
$dcName"
# Check if the Print Spooler service is running on the Domain Controller
$printSpoolerStatus = Get-Service -ComputerName
$dcName -Name Spooler -ErrorAction SilentlyContinue
if ($printSpoolerStatus -ne
$null) {
if ($printSpoolerStatus.Status -eq "Running") {
Write-Host "Print Spooler service is running on
$dcName. Disabling the service..."
# Stop and disable the Print Spooler service
Stop-Service -ComputerName
$dcName -Name Spooler -Force
Set-Service -ComputerName
$dcName -Name Spooler -StartupType Disabled
Write-Host "Print Spooler service disabled on
$dcName."
}
else {
Write-Host "Print Spooler service is not running on
$dcName."
}
}
else {
Write-Host "Print Spooler service not found on
$dcName."
}
}