#ustawienie max wieku komputerów:
$then = (Get-Date).AddDays(-90)
#Wylistowanie tych komputerów, które nie logowały się ostatnio:
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | FT Name,lastLogonDate
#Wyłączenie kont nieaktywnych komputerów:
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | Set-ADComputer -Enabled $false
#Usunięcie nieaktywnych komputerów:
Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | Remove-ADComputer