Script Overview
This script scans the ‘Users’ OU and disables accounts that haven’t logged in for 90 days.
# Get inactive users
$date = (Get-Date).AddDays(-90)
Get-ADUser -Filter 'LastLogonDate -lt $date' | Disable-ADAccount
Note: Always run this in -WhatIf mode first!