#@
#
# 1. direcotry service warning and error events for the current day
#
#
$StartTime = (Get-Date)
$ServerNames = Get-ADComputer -SearchBase “ou=domain controllers,dc=test,dc=com” -filter * | ForEach-Object { Get-ADDomainController -Identity $_.DNSHostname}
$temp = Get-Date
$final =$temp.AddDays(-1)
ForEach ($servername in $servernames){
if (Test-Connection $servername -count 1 -quiet ) {
write-host “$($servername)” -BackgroundColor Red
write-host “Warning Events:”
Get-EventLog -LogName ‘directory service’ -ComputerName $servername -after $final -Source ‘ntds general’ -EntryType ‘warning’ | format-table -Property MachineName, Index, TimeGenerated, EntryType, Source, InstanceID, Message
Write-host “Error Events:”
Get-EventLog -LogName ‘directory service’ -ComputerName $servername -after $final -Source ‘ntds general’ -EntryType ‘error’ | format-table -Property MachineName, Index, TimeGenerated, EntryType, Source, InstanceID, Message
}
else {
write-host “Server $servername is down”
}
}
$([timespan]::fromseconds(((Get-Date)-$StartTime).Totalseconds).ToString(“mm\:ss”))