From c38b9c9f58ccc969790a5a3d849e53680b3cb783 Mon Sep 17 00:00:00 2001 From: poslop Date: Fri, 20 Sep 2024 12:34:26 -0500 Subject: [PATCH] Delete DeleteOldProfiles.ps1 --- DeleteOldProfiles.ps1 | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 DeleteOldProfiles.ps1 diff --git a/DeleteOldProfiles.ps1 b/DeleteOldProfiles.ps1 deleted file mode 100644 index 0cee404..0000000 --- a/DeleteOldProfiles.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -$daysInactive = 14 # Specify the number of days of inactivity -$inactiveDate = (Get-Date).AddDays(-$daysInactive) -$homeDirectoryPath = "C:\Users" # Path to user home directories - -# Get all user profiles -Get-WmiObject Win32_UserProfile | ForEach-Object { - $profile = $_ - $userFolder = $profile.LocalPath - - # Check if the profile folder exists and get the last modification date - if (Test-Path $userFolder) { - $lastWriteTime = (Get-Item $userFolder).LastWriteTime - - if ($lastWriteTime -lt $inactiveDate) { - Write-Host "Deleting user profile: $($profile.LocalPath) Last Modified: $lastWriteTime" -ForegroundColor Red - - # Remove the user profile - $profile.Delete() - } - } -} \ No newline at end of file