Forum Discussion
Issue with date modified for NTUSER.DAT
- Feb 23, 2018
Here is the code from the script:
#Purpose: Used to set the ntuser.dat last modified date to that of the last modified date on the user profile folder.
#This is needed because windows cumulative updates are altering the ntuser.dat last modified date which then defeats
#the ability for GPO to delete profiles based on date and USMT migrations based on date.$ErrorActionPreference = "SilentlyContinue"
$Report = $Null
$Path = "C:\Users"
$UserFolders = $Path | GCI -DirectoryForEach ($UserFolder in $UserFolders)
{
$UserName = $UserFolder.Name
If (Test-Path "$Path\$UserName\NTUSer.dat")
{
$Dat = Get-Item "$Path\$UserName\NTUSer.dat" -force
$DatTime = $Dat.LastWriteTime
If ($UserFolder.Name -ne "default"){
$Dat.LastWriteTime = $UserFolder.LastWriteTime
}
Write-Host $UserName $DatTime
Write-Host (Get-item $Path\$UserName -Force).LastWriteTime
$Report = $Report + "$UserName`t$DatTime`r`n"
$Dat = $Null
}
}
It works perfectly in our domain and now the GPO (delete user profiles older than...) works for the computers Windows 10 after a restart.
In other situation, we use this script and this command :
Get-WMIObject -class Win32_UserProfile | Where {(!$_.Special) -and ($_.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-15))} | Remove-WmiObject
Why MS don’t solve this problem with a hotfix ?
There were a number of fixes to address this issue, so that the Group Policy should be working with current updated builds. If you are still having issues with the Group Policy not working please file Feedback bugs.
Thanks
Darrell
- Ami74Jun 23, 2021Copper ContributorHello Darell,
Thanks for your reply.
Do you know the KB concerned ?
(We have W10 1903 build 18362)- Darrell_GorterJun 23, 2021Former Employee
This would have been in October 20, 2020—KB4580386 (OS Builds 18362.1171 and 18363.1171) Preview (microsoft.com)
So last October.
- AmiDCSOct 29, 2021Copper Contributor
Hello Darrel,
Many thanks about the KB458038 ; )
Could you please tel me if MS have a KB for Windows 10 1703 build 15063.1596 ?
Regards.
Alexandre