Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Last active June 27, 2019 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IISResetMe/90e8c51614585103fda6218a4aa04477 to your computer and use it in GitHub Desktop.
Save IISResetMe/90e8c51614585103fda6218a4aa04477 to your computer and use it in GitHub Desktop.
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