Forum Discussion
OneDrive with FSlogix in an AVD environment how to prevent profile bloat
On for more than a day. I tested it over 8 hours of a logged on session and it did nothing.
- steveturnbull1975May 10, 2023Brass ContributorI’ve basically just created a scheduled task that runs 30 mins after a user logon. It scans the users onedrive folder and checks for any files that haven’t been accessed for more than 60 days. If there are any it uses the attrib command to set them back to online only mode. The version of fslogix we use we have the auto shrink/compaction at logoff providing it’s cleaned up enough files to warrant that it will run. We also run our own fslogix shrink script written by Jim moyle each month to help. This process has helped keep the profiles under control with minimal growth over the past few weeks.
It’s a bit ridiculous that people are having to invent their own solutions for this issue when it should just be part of a onedrive policy- sof_bradMay 17, 2023Copper ContributorIs the scheduled task you created based off the script you linked above or something different? If possible, can you share your full sanitized solution?
I am in a similar situation, but it's exacerbated by the fact that we have a very aggressive deallocation automation setup to deallocate after 2-3hrs idle.- steveturnbull1975May 18, 2023Brass Contributor
I just created it myself it’s set to run as “users” in the scheduled task security options so it’ll run as user context for any user who logs in. The trigger is set as “at log on” and “at logon of any user” with a delay task set as 30 minutes.
The action runs a vbs file
C:\windows\system32\wscript.exe “c:\profiles\onedrivecleanup.vbs”
It’s a vbs file as I wanted to hide the powershell pop-up at logon
Contents of vbs file is
Command = "powershell -nologo -command c:\profiles\onedrivecleanup.ps1”
Set shell =createobject(“WScript.Shell”)
shell.run command,0
then the powershell file contains the following
Get-childitem $env:userprofile’\onedrive - youronedrivecompanynameprobably’ -force -file -recurse |where-object {$_.lastwritetime -lt (get-date).adddays(-30)} |where attributes -eq ‘archive, reparsepoint’ | foreach { attrib.exe $_.fullname +U -P /s }
Obviously replace the oneddiveyourcompanyname with whatever onedrive folder you are interesting it scanningif you run the above in a test environment you should find for any files which haven't been modified in 30 days, it will set them back from a green tick to a blue cloud icon which means they have been removed from the container and back to online only mode.