From 0f22c9530b916f3c4c7afd25e71915b7c72806ed Mon Sep 17 00:00:00 2001 From: poslop Date: Thu, 13 Feb 2025 11:47:46 -0600 Subject: [PATCH] testing new script --- scripts/DeleteOldProfilesManual.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/DeleteOldProfilesManual.ps1 b/scripts/DeleteOldProfilesManual.ps1 index cfb69ec..38cb835 100644 --- a/scripts/DeleteOldProfilesManual.ps1 +++ b/scripts/DeleteOldProfilesManual.ps1 @@ -11,9 +11,8 @@ $ComputerName = $env:computername ForEach ($computer in $ComputerName) { $profilesFound = 0 - Try { - $profiles = Get-WmiObject -Class Win32_UserProfile -Computer $computer -EnableAllPrivileges + $profiles = Get-CimInstance -Class Win32_UserProfile } Catch { Write-Warning "Failed to retreive user profiles on $ComputerName" Exit @@ -27,7 +26,7 @@ ForEach ($computer in $ComputerName) $accountName = $account.value.split("\")[1] $profilePath = $profile.LocalPath $loaded = $profile.Loaded - $lastUseTime = [System.Management.ManagementDateTimeConverter]::ToDateTime($profile.LastUseTime) + $lastUseTime = $profile.LastUseTime $isExcluded = $False #Calculation of the login date