Get Disabled Accounts Active Directory

Get Disabled Accounts Active Directory

Import-Module ActiveDirectory

#Get-ADUser -Filter 'Name -like "*"' -SearchBase "OU=domain,DC=local" | Disable-ADAccount
#Get-ADUser -SearchBase "OU=domain,DC=local" -Filter {Enabled -eq $false} | FT samAccountName
#
$allDisabldAccounts = (Search-ADAccount -AccountDisabled).count
Write-Output "Disabled User accounts:`t`t $allDisabldAccounts"
$all = (get-aduser -Filter *).count
$allactive = $all - $allDisabldAccounts
Write-Output "Active User Accounts:`t`t $allactive"
Write-Output "All User Accounts:`t`t`t $all"

$allDisabldAccounts = Get-ADComputer -Filter * | Where-Object {$_.enabled -ne $true}
Write-Output "Disabled Computer accounts:`t`t $allDisabldAccounts"
$all = (Get-ADComputer -Filter *).count
$allactive = $all - $allDisabldAccounts
Write-Output "Active Computer Accounts:`t`t $allactive"
Write-Output "All Computer Accounts:`t`t`t $all"