Jump to content

Recommended Posts

Posted

I have disks getting full so I thought I'd run "delprof /d:150" so that it would delete all profiles that haven't been used this academic year. It says there aren't any old enough to delete, yet in file explorer I can see dozens which are dated 2020. Any thoughts please?

 

Stuart

Posted
I've given up on trying to use DelProf2 switches. It just doesn't work correctly in Windows 10. If I use the /d:xx switch, it doesn't delete any profiles, even those older than xx. If I use /d:xx /ntuserini, it deletes only profiles NEWER than xx, which is incorrect. Instead, I just manually run DelProf2.exe /u /i on machines when they're full and users complain about not being able to open/save files.
  • Thanks 1
Posted

Delprof wasn’t updated to work with Windows 10 properly last time I looked at it (there was the authors blog about it on their homepage)

 

We moved to the Windows GPO to delete profiles and it’s been rock solid since the last MS change to target the old issues with modified dates changing in upgrades. Just automatically clears profiles at start up based on the days old you set in the gpo

 

Steve

  • Thanks 2
Posted
Wasn't it something to do with which file it was looking at (.dat ring a bell?) as the last used date and there are things in Windows 10 that modify this (also anti-virus etc.)?
  • Thanks 1
Posted

The problem with the ntuser.dat file's date is down to Windows updates changing it. I noticed that the date stamp on older ntuser.dat files was always the same to within a few minutes. I found a PowerShell script on this page which changes the date stamp on it to match that of the user folder. It's not perfect as I found some profile folders with a date much older than the last logon. Running it does set a more realistic date stamp for most ntuser.dat files which means delprof2 works more reliably.

 

https://techcommunity.microsoft.com/t5/windows-deployment/issue-with-date-modified-for-ntuser-dat/m-p/102438

 

Having said that, when I started investigating the user folder on some of the DfE laptops with 64GB drives I noticed that I had not applied the Delete Profiles GPO. When I did apply it I then realised that the old user folders were vanishing at the wrong time, they did not delete during shutdown but instead shortly after startup. I realised it had two settings in the GPO, one was to run delprof2 at shutdown, but the batch file had that line commented out and the other was to enabled Delete user profiles older than (days).

 

Computer Configuration > Policies > Adminstrative Templates > System/User Profiles > Delete user profiles older than (days) - I had it set to 14. The documentation says it takes effect the next reboot after being set.

 

I have spotted some user profile folders left behind that are empty. Until I find they are causing problems I am not going to worry about them as they are not actually taking up any space.

  • Thanks 1
Posted
Delprof wasn’t updated to work with Windows 10 properly last time I looked at it (there was the authors blog about it on their homepage)

 

We moved to the Windows GPO to delete profiles and it’s been rock solid since the last MS change to target the old issues with modified dates changing in upgrades. Just automatically clears profiles at start up based on the days old you set in the gpo

 

Steve

 

Same, made a GPO for the rooms with full HDD's and cleared the profiles that way. Delprof2 just would not report any valid profiles to clean no matter what I did. Making a GPO to wipe stored profiles older than 5 days worked fine. Of course use caution if you have local profiles and allow desktop saving etc

  • Thanks 1
  • 1 month later...
Posted

Ok this is what i found as i too have now come across flawed delprof2 script

originally using /d:30 with ntuser.dat and yes found no profiles were being deleted because regardless windows 10 updates this files regularly therefore never gettiung old enough to delete

modified script /d:30 /ntuserini and found this deletes the profiles 30days from creation. looking at its properties ntuser.ini has the same mod date as created date for all profiles therefore regardless of the user logging in if the profile is older than 30days from creation it will be removed

 

So i tried to find a way of changing the ntuser.ini modify date and the only way around i have found is to echo some text >>%userprofile%\ntuser.ini during a log off or logon script. Bit messy but works ok. looking for people input. is there a more efficient way

 

i tested the group policy option but found this to also not work

Thanks

Posted
Delprof doesn't seem to work correctly for us with 10. Been looking at the GPO myself. For anyone using the GPO to delete profiles, how many days do you have it set to?

I have the students machines set to 14 days and staff to 60 days (to account for the summer holidays+buffer). GPO works well and I no longer use DelProf2.

  • Thanks 1
  • 10 months later...
Posted (edited)
I found a PowerShell script on this page which changes the date stamp on it to match that of the user folder. It's not perfect as I found some profile folders with a date much older than the last logon. Running it does set a more realistic date stamp for most ntuser.dat files which means delprof2 works more reliably.

 

https://techcommunity.microsoft.com/t5/windows-deployment/issue-with-date-modified-for-ntuser-dat/m-p/102438

 

I was recently reviewing our DelProf scripts as we were getting a lot of reports of SSD's filling up with profiles.

 

I also found that script on Microsoft Communities, which was also posted in the comments on the DelProf2 site https://helgeklein.com/free-tools/delprof2-user-profile-deletion-tool/.

 

Helge mentions at the top of that page about UWP apps not being supported as Windows locks some of the databases/registry keys.

 

We're running DelProf2 as a startup script and restart workstations daily to reduce any instances where files might be locked that would prevent the profile being fully deleted.

 

But we do often get "Could not delete key . Error: Access is denied." in the DelProf2 logs.

As far as I can tell, we've not had any profile issues though.

 

I got in touch with Helge on Twitter and he said:

I'm not sure I'll have the time for an update of Delprof2. You should be able to work around the issue you described by using a touch-like tool to copy the correct timestamp from, e.g., UseClass.dat to NTUSER.dat. Run that tool in a little script right before Delprof2

It's unlikely that Delprof2 will ever get an update to resolve the NTUSER.dat date modified issue. But the script from Microsoft Communities works well to work around it.

 

I've made a few tweaks to the script, but this has allowed us to use the /d: switch across our entire Trust reliably. We run this before we run DelProf2.

 

<#
.SYNOPSIS
   ===========================================================================
    Filename:      NTUSER.dat Date Modified Fix.ps1
    Created by:    Darrell Jividen @SSUtech
    Updated by:    George Escott @[u]georgeescott[/u]
    Updated on:    26/01/2023
   ===========================================================================

.DESCRIPTION
   Used to set the NTUSER.DAT last modified date to the last modified date of 
   the users UsrClass.dat file so that it's correct.
   Windows cumulative updates alter the NTUSER.DAT last modified date to be
   more recent that it actually is. This breaks some profile deletion tools / 
   scripts that rely on this date to remove cached profiles based on age.

.NOTES
   To be used as a scheduled task or startup script.

   https://techcommunity.microsoft.com/t5/windows-deployment/issue-with-date-modified-for-ntuser-dat/m-p/102438/page/2
   https://helgeklein.com/free-tools/delprof2-user-profile-deletion-tool/
#>

# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.3#erroractionpreference
$ErrorActionPreference = "SilentlyContinue"

# C:\Users folder
$Path = "$env:systemdrive\Users"

# Exclude user folders
$ExcludedUsers = @('Default','Public','Administrator')
$UserFolders = $Path | Get-ChildItem -Directory -Exclude $ExcludedUsers

# Check each user profile folder and update the NTUSER.dat date modified time if
# it's different from UsrClass.dat
ForEach ( $UserFolder in $UserFolders ){
   $Username = $UserFolder.Name

   # Do not proceed unless both NTUSER.DAT and UsrClass.dat exist
   if ( (Test-Path "$Path\$Username\NTUSER.DAT") -and (Test-Path "$Path\$Username\AppData\Local\Microsoft\Windows\UsrClass.dat") ){
       # Get Last Modified time for the NTUSER.DAT file
       $NTUSERDat = Get-Item "$Path\$Username\NTUSER.DAT" -Force
       $NTUSERDatLastModified = $NTUSERDat.LastWriteTime
       Write-Host "$Username - NTUSER.DAT Last Modified: $NTUSERDatLastModified"

       # Get Last Modified time for the UsrClass.dat file
       $UsrClassDat = Get-Item "$Path\$Username\AppData\Local\Microsoft\Windows\UsrClass.dat" -force
       $UsrClassDatLastModified = $UsrClassDat.LastWriteTime
       Write-Host "$Username - UsrClass.dat Last Modified: $UsrClassDatLastModified"

       # Set the NTUSER.DAT Last Modified time to the same time as the UsrClass.dat file
       if ( $NTUSERDatLastModified -ne $UsrClassDatLastModified ){
           $NTUSERDat.LastWriteTime = $UsrClassDatLastModified
           Write-Host "$Username - NTUSER.dat Last Modified date updated to match UsrClass.dat"
       } else {
           Write-Host "$Username - NTUSER.dat Last Modified date already matches UsrClass.dat"
       }

       $NTUSERDat = $null
       $UsrClassDat = $null
       Write-Host ""
   }
}

Edited by georgeescott
  • Thanks 4
Posted
GPO at 60 days plus redirected appdata works well. Profiles are only 10/20mb with redirected appdata. Even our ancient 110gb SSD light use machines dont have issues.
  • 2 weeks later...
Posted
Delprof wasn’t updated to work with Windows 10 properly last time I looked at it (there was the authors blog about it on their homepage)

 

We moved to the Windows GPO to delete profiles and it’s been rock solid since the last MS change to target the old issues with modified dates changing in upgrades. Just automatically clears profiles at start up based on the days old you set in the gpo

 

Steve

 

HI @Steve21,

 

Which GPO was this and may I ask what your settings are?

 

Thanks

 

Gareth

Posted

Computer Configuration > Policies > Administrative Templates > System > User Profiles

 

Delete user profiles older than a specified number of days on system restart

 

 

It used to be a bit hit and miss but it appears to work now rather well

  • 3 months later...
Posted

What’s with the group policy user profiles. There was a period of time this wasn’t working. Is it working again now? I have several sites that used to have delprof but that broke and then the group policy but that also broke.

I have techies running delprof manually and it’s a bit of ball ache especially if you have no remote management software on site

Posted
What’s with the group policy user profiles. There was a period of time this wasn’t working. Is it working again now? I have several sites that used to have delprof but that broke and then the group policy but that also broke.

I have techies running delprof manually and it’s a bit of ball ache especially if you have no remote management software on site

 

We have found it working well recently. However it's not granular enough for us. There needs to be a way of excluding certain profiles - which DelProf2 offered us. Otherwise it works well. We have it set for 30 days.

 

Gareth

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...