Get-ADDomainController
Get-ADDomainController is useful to easily return all, or a subset of your domain controllers. This can be easily filtered by type, OS, AD Site, or a number of other values.
Example usage
Define the parameters
Identity takes a range of identifiers for the object. These include "Distinguished Name", "GUID", "SID", and "samaccountname".
Service takes the following :
PrimaryDC or 1
GlobalCatalog or 2
KDC or 3
TimeService or 4
ReliableTimeService or 5
ADWS or 6
Filter uses the format {isreadonly -eq $true} against most of the object properties.
There are more options, use get-help cmdlet for all options
In a script
For each Read / Write DC, tell me how much memory the lsass process is using in Mb.
I have covered How to find a GC, here are some others :
Get-ADDomainController is useful to easily return all, or a subset of your domain controllers. This can be easily filtered by type, OS, AD Site, or a number of other values.
Example usage
#get all read only DC's
Get-ADDomainController -filter {isreadonly -eq $true}
# get the domain controller DC1
Get-ADDomainController -identity "DC1"
# get the PDCE for the domain
Get-ADDomainController -Discover -Service "PrimaryDC"}
# get a GC but force it to rediscover (clear any cached DC)
Get-ADDomainController -Discover -Service "GlobalCatalog" -ForceDiscover
Define the parameters
Identity takes a range of identifiers for the object. These include "Distinguished Name", "GUID", "SID", and "samaccountname".
Service takes the following :
PrimaryDC or 1
GlobalCatalog or 2
KDC or 3
TimeService or 4
ReliableTimeService or 5
ADWS or 6
Filter uses the format {isreadonly -eq $true} against most of the object properties.
There are more options, use get-help cmdlet for all options
In a script
For each Read / Write DC, tell me how much memory the lsass process is using in Mb.
foreach ($RWDC in $(Get-ADDomainController -filter { isreadonly -eq $false })) {Powershell without the Management pack
$lsass = get-process -ComputerName $rwdc.name -Name lsass
"Current memory usage for lsass on $($rwdc.name) is $($lsass.WorkingSet / 1mb)Mb"
}
I have covered How to find a GC, here are some others :
#get all DC's in the domain
$domain = [System.DirectoryServices.ActiveDirectory.domain]::getcurrentdomain()
$Domain.FindAllDomainControllers()
#read only DC's
#search AD for DC's with a primary group ID of 521
#or get memebers of the group "Enterprise Read-only Domain Controllers"
#get pre-staged RODC objects
#search AD and filter DC's for useraccountcontrol value of 83890178
Comments
Post a Comment