Fixed logic

This commit is contained in:
Erik Eckert 2023-09-29 10:49:37 -06:00
parent b82d93eb0e
commit 137b933ec1

View File

@ -4,9 +4,9 @@ if (!($cred)) {
$cred = Get-Credential -Message "Enter your domain admin login:"
}
$AgedOutDays = -365 #store this as a negative number. How many days back should the PC have changed its password
$AgedOutDays = -270 #store this as a negative number. How many days back should the PC have changed its password
$CSVPATH = 'C:\Users\eeckert\Downloads\AD-ToDelete.csv'
$computers = get-adcomputer -filter {(Enabled -eq $False)} -properties passwordlastset | where passwordlastset -le (get-date).adddays($AgedOutDays)
$computers = get-adcomputer -filter { (Enabled -eq $True) } -properties passwordlastset | where passwordlastset -le (get-date).adddays($AgedOutDays)
foreach ($computer in $computers) {
$Output = 'Moving ' + $computer.name + ' to disabled OU.'