PowerShell Lab
Build, find and save PowerShell
Reviewed templates and commands with requirements, permissions and risk spelled out. Nothing here runs anything — you copy, review and run it yourself.
Search pages, tools, PowerShell commands and ports
Active Directory
List disabled user accounts, optionally with last logon and OU.
Leave empty to search the whole domain.
Leave empty to use the nearest domain controller.
0 = no limit.
1# Disabled user accounts2# Generated by Antinon IT Hub (forum.antinon.se). Review before running.3#Requires -Modules ActiveDirectory4Get-ADUser -Filter 'Enabled -eq $false' -Properties LastLogonDate |5 Sort-Object Name |6 Select-Object Name,7 SamAccountName,8 UserPrincipalName,9 LastLogonDate,10 @{ Name = 'OU'; Expression = { $_.DistinguishedName -replace '^CN=.+?(?<!\\),', '' } } |11 Format-Table -AutoSizeOnly reads information. Nothing is changed. Templates are reviewed, but always test against a single object first.