$alldomainadmins=Get-ADGroupMember -Identity "Domain Admins"
When you have a variable of all AD domain admin objects you can do some interesting filtering. for instance you can get all domain admins with a certain common name:
$alldomainadmins|where {$_.distinguishedName -like "*internal*"}
another interesting application of this is the search for disabled accounts and logoncount like this:
foreach($member in $alldomainadmins){
$testuser=Get-ADUser -Identity $member
$logoncount=Get-ADUser -Identity $member -pr logoncount
$create=Get-ADUser -Identity $member -pr whenCreated
If($testuser.enabled -ne "true"){ $testuser.Name +" = disabled and has logged on "+$logoncount.logoncount+" times "}
}
You should have a go and play around with the Get-AD* cmdlets, they are very powerfull!Have fun, till next time
No comments:
Post a Comment