Skip to content

Commit 804c09d

Browse files
authored
Disable Old Accounts.txt
1 parent 46287cd commit 804c09d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Export list of computer accounts not logged on or seen in the last 365 days
2+
$datecutoff = (Get-Date).AddDays(-365)
3+
Get-ADComputer -Properties LastLogonDate -Filter {LastLogonDate -lt $datecutoff} | Sort LastLogonDate | FT Name, LastLogonDate -Autosize | Out-File C:\MCL\ComputerLastLogonDate.txt
4+
5+
6+
#Disable computer accounts not logged on or seen in the last 365 days
7+
$datecutoff = (Get-Date).AddDays(-365)
8+
Get-ADComputer -Properties LastLogonDate -Filter {LastLogonData -lt $datecutoff} | Set-ADComputer -Enabled $false
9+

0 commit comments

Comments
 (0)