Wednesday 22 April 2020

Event log Count in Domain Controller


#List of Domain Controller to pull the events and get the count

$DCs = Get-ADDomainController -Filter * | Select-Object -ExpandProperty Name

foreach ($dc in $dcs){

    $log = (Get-EventLog -LogName 'Directory Service' -ComputerName $dc | Where-Object {$_.EventID -eq '4770'}).count

    Write-Host "Name of $DC No of event in count $log"

    } 

No comments:

Post a Comment