Skip to content

Instantly share code, notes, and snippets.

@ScriptingPro
Created July 29, 2023 00:22
Show Gist options
  • Save ScriptingPro/34ff9cd6c783fe2f029f3541800ed61a to your computer and use it in GitHub Desktop.
Save ScriptingPro/34ff9cd6c783fe2f029f3541800ed61a to your computer and use it in GitHub Desktop.
AD Queries Against Each Domain Controller
# User Attributes - Check if user attributes replicated to all DCs
Get-ADDomainController -Filter * -pv dc | %{get-aduser userid -server $dc.name -Properties * } | select {$dc.name}, LastBadPasswordAttempt,badPwdCount,LockedOut,PasswordLastSet | ft -AutoSize
# Group Members - Check if group members replicated to all DCs
Get-ADDomainController -Filter * -pv dc | %{Get-ADGroup groupname -server $dc.name -Properties members} | select {$dc.name}, {($_.members | Get-ADObject -server $dc.name -Properties samaccountname).samaccountname -join ","} | ft -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment