# list all commands for active directory
Get-Command -Module ActiveDirectory -Name get*
# list all computers with SID in a AD-Domain
Get-ADComputer -Filter *
# count all computers that are meber of the domain
(Get-ADComputer -Filter *).count
# list all commands for active directory
Get-Command Get-Ad*
# show all computer that are NOT deactivated
Get-ADUser -ldapfilter "(&(&(objectCategory=user)(userAccountControl=512)))" | where-object -property enabled -eq true
# count all ad-users
(Get-ADUser -Filter "Name -like '*'").count
# show last login of a ad-user
Get-ADUser "<Name>" -Properties LastLogonDate | FT -Property Name, LastLogonDate -A
# show last login date of all computers
Get-ADUser -Filter {(Enabled -eq $true)} -Properties LastLogonDate|
select samaccountname, Name, LastLogonDate | Sort-Object LastLogonDate
# show all locked accounts
Search-ADAccount -lockedout
# unlock an account
Get-ADUser -Identity <Name> | Unlock-ADAccount
# show information of all computers
Get-ADComputer -filter 'name -like "*"' -Properties * | select name,OperatingSystem,IPv4-Address
# count all ad-computers
(Get-ADComputer -Filter "Name -like '*'").count
# show domain-controlers
Get-Addomaincontroller
# show domain-controlers in a forest
(Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }
# show FSMO Roles
Get-ADDomainController -Filter {OperationMasterroles -like "PDC*"} |
Format-list Hostname, OperationMasterrole Get-ADDomain | Select InfrastructureMaster, RID-Master, PDCEmulator
Get-ADComputer(Get-ADDomainController -Discover -Service
"PrimaryDC").Name -Properties * |
Format-List DNSHostname,OperatingSystem,OperatingSystemVersion
Get-ADDomainController | Format-List hostname, IPV4Address, OperationMasterroles, OperatingSystem
Get-ADForest | Select-Object DomainNamingMaster, SchemaMaster