From dac40756764e78b5a10b3702f041402c4d929830 Mon Sep 17 00:00:00 2001 From: poslop Date: Mon, 10 Feb 2025 12:06:29 -0600 Subject: [PATCH] added exclusion logic --- scripts/DeleteOldProfilesNetProfile.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/DeleteOldProfilesNetProfile.ps1 b/scripts/DeleteOldProfilesNetProfile.ps1 index 3900491..1c35060 100644 --- a/scripts/DeleteOldProfilesNetProfile.ps1 +++ b/scripts/DeleteOldProfilesNetProfile.ps1 @@ -7,10 +7,10 @@ $excludedProfiles = @("Default User", "administrator") $inactiveDate = (Get-Date).AddDays(-$daysInactive) +$profiles = Get-WmiObject Win32_UserProfile # Get all user profiles -Get-WmiObject Win32_UserProfile | :Loop ForEach-Object { - $profile = $_ +:Loop ForEach-Object ($profile in $profiles) { $userFolder = $profile.LocalPath $userName = $profile.LocalPath.Split('\')[-1] # Get the username from the folder path $nameIsExcluded = false