-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisable_Computers.ps1
More file actions
11 lines (10 loc) · 967 Bytes
/
Disable_Computers.ps1
File metadata and controls
11 lines (10 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
$computers=get-adcomputer -Filter * -Properties * | select @{Label="Name";Expression={$_.name}}, @{Label="OS";Expression={$_.operatingsystem}}, @{Label="Distinguishedname";Expression={$_.'distinguishedname'}}, @{Label="Password";Expression={$_.'ms-Mcs-AdmPwd'}}, @{Label="PassLastSet";Expression={$_.PasswordLastSet}}, @{Label="PassExpired";Expression={$_.'PasswordExpired'}}, @{Label="PassRequired";Expression={$_.'PasswordNotRequired'}}, @{Label="Modified";Expression={$_.'Modified'}}, @{Label="LogonCount";Expression={$_.'logonCount'}}, @{Label="LastLogonDate";Expression={$_.'LastLogonDate'}}
#$Results=@()
foreach($computer in $computers){
if($computer.lastlogondate -le ((get-date).adddays(-365))){
Disable-ADAccount -Identity $computer.distinguishedName -WhatIf
Move-ADObject -Identity $computer.distinguishedname -TargetPath "OU=Computers,OU=Termindations,DC=,DC=com" -WhatIf
#$results+=$computer.name
}
}
#$results.count