-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeleteOlderThanDays #31
Comments
experiencing the same thing. We run this script weekly and set the 'deleteolderthandays' to 90....however each week when the script runs, it changes the VHDX modified date, thus never reaching the 'deleteolderthandays' value. Was thinking of looking at last modified date on ntuser.dat or .ost file, but since it's not mapping a drive, I'm not sure what the best way would be. Anyone have any thoughts? |
There would be an easy solution for this: Edit: |
We are experiencing the same issue, One thought I had would be to do the check on the .meta file? as that should only update when the user has logged in and attached their profile? |
yeah, or ntuser.dat or something like that. |
For ntuser.dat you would still need to mount the .vhdx to check the time stamp though no? Wouldn't mounting it still change the modified stamp? |
Looks like the meta file is only for the cloud cache feature. If it's outside the VHDX file then yeah, that would be ideal. For customers that aren't using cloud cache, they might not have a choice other than to mount. |
Ah good catch, we are using Cloud Cache at the moment and it sits outside the .VHDX, only thing is I don't understand the Powershell enough to add in the check against the meta file. |
MrFly had a good suggestion above, that would work. Or you could do a get-childitem on the meta file, to grab the lastAccessTime and LastWriteTime values. Then do a condition in the code below if the meta file exists, use that files LastAccessTime and LasteWriteTime instead of the VHDX file.
|
Yeah I was thinking about using it but I don't know where to add the Get-Childitem to find the meta file. Will do some more digging and see where I can put it. |
If you look into the development branch, I've written code there to account
fo this which you can use.
Jim
…On Fri, 11 Feb 2022 at 15:30, Ryan Swanepoel ***@***.***> wrote:
Yeah I was thinking about using it but I don't know where to add the
Get-Childitem to find the meta file. Will do some more digging and see
where I can put it.
—
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE365O6RPPLDTJ4CSR3DIMDU2UTQPANCNFSM4V5OEENQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hi Jim thanks for the response! Am I correct in thinking I would just need to add the changes in commit (5dc8aa7) to both Dismount-FSLDisk.ps1 and Optimize-OneDisk.ps1? which will then set the LastWriteTimeUTC once the disk is unmounted? Does it need a -SetLastWriteTime switch when calling the script after making the changes? |
Yep that should do it.
…On Tue, 15 Feb 2022 at 09:54, Ryan Swanepoel ***@***.***> wrote:
Hi Jim thanks for the response!
Am I correct in thinking I would just need to add the changes in commit (
5dc8aa7
<5dc8aa7>)
to both Dismount-FSLDisk.ps1 and Optimize-OneDisk.ps1? which will then set
the LastWriteTimeUTC once the disk is unmounted?
Does it need a -SetLastWriteTime switch when calling the script after
making the changes?
—
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE365OZOIFRYPEJRLEGLZWLU3IPGJANCNFSM4V5OEENQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
I decided against the addition of a switch for the feature for reasons of
simplicity, but feel free to put it in your script :)
Jim
…On Tue, 15 Feb 2022 at 17:11, Jim Moyle ***@***.***> wrote:
Yep that should do it.
On Tue, 15 Feb 2022 at 09:54, Ryan Swanepoel ***@***.***>
wrote:
> Hi Jim thanks for the response!
>
> Am I correct in thinking I would just need to add the changes in commit (
> 5dc8aa7
> <5dc8aa7>)
> to both Dismount-FSLDisk.ps1 and Optimize-OneDisk.ps1? which will then set
> the LastWriteTimeUTC once the disk is unmounted?
>
> Does it need a -SetLastWriteTime switch when calling the script after
> making the changes?
>
> —
> Reply to this email directly, view it on GitHub
> <#31 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AE365OZOIFRYPEJRLEGLZWLU3IPGJANCNFSM4V5OEENQ>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
Thanks so much Jim, finally got some time to get it working with the changes in the Dev branch. One quick thought, with the "DeleteOlderThan" option it is only removing the disk itself and leaving behind the meta file and folder structure. Is this by design? Can you see any issue with remove the entire folder? so for example changing from Remove-Item $Disk.FullName to Remove-Item $Disk.DirectoryName as this would clean up the entire profile (Disks and meta). |
Many configurations will have Profiles and ODFC container vhds in the same directory, so I would not think it is always safe to just delete the directory. The meta file is a more recent addition in non-ccd configurations, and should be cleaned up when the vhd is cleaned up.
From: Ryan Swanepoel ***@***.***>
Sent: Thursday, March 17, 2022 5:06 AM
To: FSLogix/Invoke-FslShrinkDisk ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [FSLogix/Invoke-FslShrinkDisk] DeleteOlderThanDays (#31)
Thanks so much Jim, finally got some time to get it working with the changes in the Dev branch.
One quick thought, with the "DeleteOlderThan" option it is only removing the disk itself and leaving behind the meta file and folder structure. Is this by design?
Can you see any issue with remove the entire folder? so for example changing from Remove-Item $Disk.FullName to Remove-Item $Disk.Path as this would clean up the entire profile (Disks and meta).
—
Reply to this email directly, view it on GitHub <#31 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB6ERMLIMTPDWNG5L244T3LVAMGZ7ANCNFSM4V5OEENQ> .
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/AB6ERMLD64FYOBU7YQEDBDTVAMGZ7A5CNFSM4V5OEEN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOH7JQ43Q.gif> Message ID: ***@***.*** ***@***.***> >
|
@lordjeb Agreed but while doing some testing today when the script deletes the disk it leaves behind the meta file, we are currently using CC in our environment. What I was thinking to do was have the same checks against it as the disk in terms of validating the last write time and if its less than your set amount of days remove it. An additional check could also be to make sure the profile folder is empty before removing. |
Nope, can't see an issue with removing the folder, it's a good idea I
should implement
Jim
…On Thu, 17 Mar 2022 at 11:06, Ryan Swanepoel ***@***.***> wrote:
Thanks so much Jim, finally got some time to get it working with the
changes in the Dev branch.
One quick thought, with the "DeleteOlderThan" option it is only removing
the disk itself and leaving behind the meta file and folder structure. Is
this by design?
Can you see any issue with remove the entire folder? so for example
changing from Remove-Item $Disk.FullName to Remove-Item $Disk.Path as this
would clean up the entire profile (Disks and meta).
—
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE365O7NMWWJLXKKWJGH3ZDVAMGZ7ANCNFSM4V5OEENQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Can/Has this been implemented? |
As MrFly said above, both lastaccesstime and lastwritetime have to be reset after the disk is dismounted. otherwise, the olderthan logic which picks the "maximum" between the two dates will always pick up the most recent i.e. LastAccessTime over LastWriteTime. I also had to feed each call to DisMount-FslDisk function with these switches. i.e. Great work and effort Jim - thanks much |
Would anyone mind sharing the full script that works for this, please? |
Hi can someone please share the script? :) |
Would it be possible to share the changes you made? I made the changes from the dev branch but the Date modified still changes. Thank you in advance! |
Hi,
I´ve just tried your script and the shrink function works perfect.
But I cant seem to delete VHDX files that are really old.
When I run
.\Invoke-FslShrinkDisk.ps1 -Path "path to profile" -DeleteOlderThanDays 30
Nothing happens. The profile was last used in 2020-06-11.
What am I missing?
Thanks in advance
The text was updated successfully, but these errors were encountered: