Skip to content

Commit

Permalink
Create Disable-Inactive-Users.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
rswio authored Jan 26, 2025
1 parent 84e4638 commit 4bdfb93
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Active Directory/Disable-Inactive-Users.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$Threshold = (Get-Date).AddDays(-180) # Adjust the inactivity threshold
Get-ADUser -Filter {LastLogonDate -lt $Threshold} | ForEach-Object {
Disable-ADAccount -Identity $_.SamAccountName
Write-Output "Disabled inactive user: $($_.SamAccountName)."
}

0 comments on commit 4bdfb93

Please sign in to comment.