Additional Script Updates

This commit is contained in:
Andrew Amason
2025-05-19 15:19:36 -04:00
parent ec2b22290a
commit 9c8438d7d1
136 changed files with 1595 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# Detection Script: Detect_InactiveUsers.ps1
# Define the inactivity threshold in days
$inactivityThreshold = 90
# Get the current date
$currentDate = Get-Date
# Get all user accounts
$userAccounts = Get-LocalUser
foreach ($user in $userAccounts) {
# Check the last logon date
$lastLogonDate = (Get-LocalUser -Name $user.Name).LastLogon
if ($lastLogonDate -lt $currentDate.AddDays(-$inactivityThreshold)) {
Write-Output "Inactive user account detected: $($user.Name)"
exit 1
}
}
Write-Output "No inactive user accounts detected."
exit 0

View File

@@ -0,0 +1,23 @@
# Remediation Script: Remediate_InactiveUsers.ps1
# Define the inactivity threshold in days
$inactivityThreshold = 90
# Get the current date
$currentDate = Get-Date
# Get all user accounts
$userAccounts = Get-LocalUser
foreach ($user in $userAccounts) {
# Check the last logon date
$lastLogonDate = (Get-LocalUser -Name $user.Name).LastLogon
if ($lastLogonDate -lt $currentDate.AddDays(-$inactivityThreshold)) {
# Disable inactive user account
Disable-LocalUser -Name $user.Name
Write-Output "Disabled inactive user account: $($user.Name)"
}
}
Write-Output "Inactive user accounts have been disabled."