none
Profile Container Last Accessed RRS feed

  • Question

  • Hello group,

    We need to delete all profile containers that have not been accessed in x amount of months or days. How can we scan a directory and determine the last access date for the containers?

    Thanks

    Wednesday, September 9, 2020 5:56 PM

Answers

  • Make sure the following registry key is set:

    HKLM\SYSTEM\CurrentControlSet\Control\FileSystem
    DWORD: NtfsDisableLastAccessUpdate
    Value: 0

    OR

    Excute following in an elevated prompt:
    fsutil behavior set DisableLastAccess 0

    Reboot after set.

    Now you can open powershell and do:
    gci -recurse . | select name,lastaccesstime,psparentpath |sort lastaccesstime

    • Marked as answer by BarryUWEDU Thursday, September 24, 2020 12:10 AM
    Wednesday, September 23, 2020 11:02 PM

All replies

  • Make sure the following registry key is set:

    HKLM\SYSTEM\CurrentControlSet\Control\FileSystem
    DWORD: NtfsDisableLastAccessUpdate
    Value: 0

    OR

    Excute following in an elevated prompt:
    fsutil behavior set DisableLastAccess 0

    Reboot after set.

    Now you can open powershell and do:
    gci -recurse . | select name,lastaccesstime,psparentpath |sort lastaccesstime

    • Marked as answer by BarryUWEDU Thursday, September 24, 2020 12:10 AM
    Wednesday, September 23, 2020 11:02 PM
  • Thank you. I did something similar with the help of someone better at scripting than me. Apologies to the group for not coming back to update post! Looks like "lastaccesstime" would be a better option. This is the final script I used after fist checking without Remove-item.

    $Path = "F:\Student_FX$"
    $DaysOld = -90
    $CurrentDate = Get-Date
    $DeleteDate = $CurrentDate.AddDays($DaysOld)
    Get-ChildItem $Path -Recurse | Where-Object {$_.LastWriteTime -lt $DeleteDate} | Remove-Item -Force -Recurse

    

    Thursday, September 24, 2020 12:10 AM