Instantly share code, notes, and snippets.

@mikerodionov mikerodionov/ADDSCHK.ps1
Last active Dec 19, 2018

Embed
What would you like to do?
ADDSCHK
# ADDS Domain quick check
# v.1.0
# Mikhail Rodionov - mikerodionov.com
Function ADDSCHK ()
{
$pc=hostname
$PC_OU=(Get-ADComputer $pc).DistinguishedName
#Get total number of users (enabled and disabled)
$TNU=(Get-ADUser -filter *).count
#Get total number of enabled users
$TNEU=(Get-AdUser -filter * |Where {$_.enabled -eq "True"}).count
#Get total number of disabled users
$TNDU=(Get-ADUser -filter * |Where {$_.enabled -ne "False"}).count
#Get number of groups
$TNG=(Get-ADGroup -filter *).count
#Get Forest Functional Level
$FFL=(Get-ADForest).ForestMode
#Get Domain Functional Level
$DFL=(Get-ADDomain).DomainMode
write-host 'Current server organizational unit:' $PC_OU -ForegroundColor Green
write-host 'Total number of domain users is:' $TNU -ForegroundColor Green
write-host 'Total number of enabled domain users is:' $TNEU -ForegroundColor Green
write-host 'Total number of disabled domain users is:' $TNDU -ForegroundColor Green
write-host 'Total number of domaim groups is:' $TNG -ForegroundColor Green
write-host 'Forest Functional Level is:' $FFL -ForegroundColor Green
write-host 'Domain Functional Level is:' $DFL -ForegroundColor Green
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment