Last active
June 27, 2019 01:14
-
-
Save IISResetMe/90e8c51614585103fda6218a4aa04477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(-not (Get-CimInstance -ClassName Win32_ComputerSystem -Property DomainRole).DomainRole -band 4){ | |
# Computer's not a DC | |
return | |
} | |
$logProperties = @{ | |
LogName = 'System' | |
Source = 'RIDPoolTracker' | |
} | |
if (-not(Get-Eventlog -List | Where-Object {$_.LogDisplayName -eq $logProperties.LogName})) { | |
New-EventLog @logProperties | |
} | |
# execute the ridmanager diagnostic locally | |
$rIDTest = @( dcdiag.exe /test:ridmanager /v ) | |
# grab the RID allocation pool range from the output | |
if($rIDTest -cmatch 'rIDAllocationPool is (\d+ to \d+)'){ | |
# log new range to the event log | |
$message = $Matches[1] | |
Write-EventLog "New rIDAllocationPool: $message" -EventId 100 @logProperties | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment