# Import Active Directory Module if it's not already loaded
if (-not (Get-Module -Name ActiveDirectory)) {
    Import-Module ActiveDirectory
}

# Define how recent is "recently" (e.g., past 7 days)
$daysAgo = (Get-Date).AddDays(-7)

# Find recently disabled accounts
$disabledAccounts = Get-ADUser -Filter {Enabled -eq $false -and whenChanged -ge $daysAgo} -Properties whenChanged, Enabled

# Display the results
if ($disabledAccounts) {
    $disabledAccounts | Select-Object Name, SamAccountName, whenChanged | Format-Table -AutoSize
} else {
    Write-Host "No recently disabled accounts found."
}

By Rudy