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,24 @@
# Define the inactivity threshold in days
$inactivityThreshold = 90
# Get the current date
$currentDate = Get-Date
# Get all user profiles on the endpoint
$userProfiles = Get-WmiObject -Class Win32_UserProfile | Where-Object { $_.Special -eq $false }
foreach ($profile in $userProfiles) {
# Get the last use time of the profile
$lastUseTime = [Management.ManagementDateTimeConverter]::ToDateTime($profile.LastUseTime)
# Calculate the number of days since the profile was last used
$daysInactive = ($currentDate - $lastUseTime).Days
if ($daysInactive -ge $inactivityThreshold) {
# Exit with code 1 to indicate an issue was detected
exit 1
}
}
# Exit with code 0 to indicate no issues were detected
exit 0

View File

@@ -0,0 +1,24 @@
# Define the inactivity threshold in days
$inactivityThreshold = 90
# Get the current date
$currentDate = Get-Date
# Get all user profiles on the endpoint
$userProfiles = Get-WmiObject -Class Win32_UserProfile | Where-Object { $_.Special -eq $false }
foreach ($profile in $userProfiles) {
# Get the last use time of the profile
$lastUseTime = [Management.ManagementDateTimeConverter]::ToDateTime($profile.LastUseTime)
# Calculate the number of days since the profile was last used
$daysInactive = ($currentDate - $lastUseTime).Days
if ($daysInactive -ge $inactivityThreshold) {
# Log the profile that is inactive
Write-Output "Inactive profile detected: $($profile.LocalPath) - Last used: $lastUseTime"
# Optionally, remove the inactive profile
# Remove-WmiObject -InputObject $profile
}
}