We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 46287cd commit 804c09dCopy full SHA for 804c09d
Active Directory/Disable Old Accounts.txt
@@ -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
8
+Get-ADComputer -Properties LastLogonDate -Filter {LastLogonData -lt $datecutoff} | Set-ADComputer -Enabled $false
9
0 commit comments