Forum Discussion

Travis_78's avatar
Travis_78
Iron Contributor
Dec 05, 2022

OneDrive with FSlogix in an AVD environment how to prevent profile bloat

We are implementing onedrive to hold known folders (Documents, Pictures, Desktop) and want these files to be "on demand" by default. We have it set via GPO. The main question is, how do I make sure that the files are dehydrated within our 14 day timeframe? We set up storagesense to do it, but how does storagesense have access to unmounted user profiles if storagesense only runs once per day?

 

Is there an Microsoft supported way of handling Onedrive with FSlogix profiles using storagesense? It appears that as it is now, users could download files over time and they'd never get cleaned up automatically, causing massive storage use as users bring more data in via onedrive.

25 Replies


  • It sounds like you are implementing OneDrive Known Folder Move and want to ensure that files are dehydrated within a certain timeframe.

    To address your first question about Storage Sense, it is correct that Storage Sense only runs once per day by default. However, you can configure Storage Sense to run more frequently or on a custom schedule. To do this, you can use Group Policy to configure the "Configure Storage Sense schedule" setting under "Computer Configuration\Administrative Templates\System\Storage Sense".

    As for your second question about OneDrive with FSLogix profiles using Storage Sense, there is not currently a Microsoft-supported solution for this specific scenario. However, there are a few options you can consider:

    Use third-party tools: There are third-party tools available that can help manage the storage used by OneDrive Known Folder Move, such as 2BrightSparks' SyncBackPro or Insync. These tools can be configured to automatically remove files that have not been accessed within a certain timeframe.

    Use a script or scheduled task: You could also create a script or scheduled task that periodically checks for files that have not been accessed within a certain timeframe and removes them. This can be done using PowerShell or another scripting language.

    Use a combination of Storage Sense and third-party tools or scripts: You could use Storage Sense to dehydrate files that have not been accessed within a certain timeframe, and then use a third-party tool or script to remove any remaining files that have not been accessed within a longer timeframe.
  • Is there any way to make storage sense run more often than once a day? I was trying to test it today setting the gpo and left my session connected for 6 hours and nothing was removed from onedrive cache. Does the storage sense only run randomly during the day or does something trigger it to run? If it only runs once a day unless your machine is running 24/7 it seems like it’s not a useful feature for avd?
    • Micha118835's avatar
      Micha118835
      Copper Contributor

      steveturnbull1975 

      You can try to create a scheduled Task with the Command "c:\windows\System32\cleanmgr.exe /autoclean /d C:"  on User Logon with a delay of 5 or 10 Minutes.
      This will trigger a cleanup for the User.

      When you use the Powershell Script for configure Storage Sense with OneDrive, this command also cleanup OneDrive Files.

      • steveturnbull1975's avatar
        steveturnbull1975
        Brass Contributor
        Thanks this give me a direction on where to look for a solution. I didn’t bother with storage sense because it seems like not a useful feature for vdi sessions unless someone is logged
        On for more than a day. I tested it over 8 hours of a logged on session and it did nothing.
    • Travis_78's avatar
      Travis_78
      Iron Contributor
      I wish I knew. Moving known folders for one drive seems like a thing Microsoft is pushing, but they dont seem to have a proper way of keeping things clean in an AVD environment. Theres no real straightforward documentation on this fact. They dont ever mention AVD in this configuration, its always windows 10 desktops..
  • hanifaz's avatar
    hanifaz
    Copper Contributor

    Hi Travis_78 this is a known issue, when you or the user delete files, fslogix vhd(x) does not compact itself. Here is a solution for you if you are running the latest fslogix version:

    Enable VHD Disk Compaction using the Registry

    To enable VHD Disk Compaction using the registry, you'll need to set the following registry value:

    • Key: HKLM\SOFTWARE\FSLogix\Apps
    • Value name: VHDCompactDisk
    • Value type: DWORD
    • Value data: 1

    You can do this with PowerShell:

    1. Open an elevated PowerShell prompt and run the following commands:

      Set-ItemProperty -Path "HKLM:\SOFTWARE\FSLogix\Apps" -Name VHDCompactDisk -PropertyType DWORD -Value 1 -Force
      
    2. Restart the computer.

    • Travis_78's avatar
      Travis_78
      Iron Contributor

      hanifaz Yes, but how do you get the files deleted in the first place? Profile compaction is helpful when they finally get the bugs ironed out on the latest FSlogix, but before that, you need storage sense or something that will clear the OneDrive cache store after X amount of time. So far, I don't see that storage sense runs on AVD servers where you can trust it to keep the profile clean. 

       

      Run a test where you push a GPO that has storage sense dehydrate any OneDrive files opened less than a day. Come back after a day and you see that the files are still local to the profile and have not been set back to online only, which is Storage Senses's job.

      • Micha118835's avatar
        Micha118835
        Copper Contributor

        Travis_78 

         

        Try using this Powershell Script in Autostart.

        This will activate OneDrive CleanUp for every Connected OneDrive Account or Sharepoint Site.
        Data in OneDrive Cache will be flushed every Day.

         

        $EnableStorageSense = 1
        $RunInterval = 1
        $DeleteTempFiles = 1
        $DeleteRecycleBinContent = 1
        $DeleteRecycleBinInterval = 1
        $DeleteDownloadsContent = 0
        $DeleteDownloadsInterval = 0
        $DeleteOneDriveContent = 1
        $DeleteOneDriveInterval = 1

        function Set-RegistryValue
        {
        param(
        [string]$RegPath,
        [string]$RegName,
        $RegValue,
        [ValidateSet("String","ExpandString","Binary","Dword","MultiString","Qword")]
        [string]$RegType = "String"
        )
        If (!(Test-Path -Path $RegPath))
        {
        Write-Output "Creating the registry key $RegPath"
        New-Item -Path $RegPath -Force | Out-Null
        }
        else
        {
        $RegPath.Property
        Write-Output "$RegPath already exist"
        }
        If ($RegName)
        {
        $CheckReg = Get-Item -Path $RegPath

        If ($CheckReg.GetValue($RegName) -eq $null)
        {
        Write-Output "Creating the registry value $RegName in $RegPath"
        New-ItemProperty -Path $RegPath -Name $RegName -Value $RegValue -PropertyType $RegType | Out-Null
        }
        else
        {
        Write-Output "Modifying the registry value $RegName in $RegPath"
        Set-ItemProperty -Path $RegPath -Name $RegName -Value $RegValue | Out-Null
        }
        }
        }

        # Storage Sense registry location
        $StoragePolicyRegKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy"

        # Enable Storage Sense
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "01" -RegType DWORD -RegValue $EnableStorageSense

        # Set 'Run Storage Sense' to specified interval
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "2048" -RegType DWORD -RegValue $RunInterval

        # Enable 'Delete temporary files that my apps aren't using'
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "04" -RegType DWORD -RegValue $DeleteTempFiles

        # Set 'Delete files in my recycle bin at the specified interval
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "08" -RegType DWORD -RegValue $DeleteRecycleBinContent
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "256" -RegType DWORD -RegValue $DeleteRecycleBinInterval

        # Set 'Delete files in my Downloads folder at the specified interval
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "32" -RegType DWORD -RegValue $DeleteDownloadsContent
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "512" -RegType DWORD -RegValue $DeleteDownloadsInterval

        # Suppress Storage Sense notifications
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "StoragePoliciesNotified" -RegType DWORD -RegValue 1
        Set-RegistryValue -RegPath $StoragePolicyRegKey -RegName "CloudfilePolicyConsent" -RegType DWORD -RegValue 1

        # Prerequisite for OneDrive cleanup configuration, get the user SID
        $User1 = New-Object System.Security.Principal.NTAccount($env:userDOMAIN, $env:USERNAME)
        $GetSID = $User1.Translate([System.Security.Principal.SecurityIdentifier])
        $UserSID = $GetSID.Value

        # Configure OneDrive cleanup for all OneDrive providers configured
        # Get OneDrive providers
        $OneDriveProviders = Get-ChildItem -Path HKCU:\Software\SyncEngines\Providers\OneDrive\
        ForEach ($ProviderKeys in $OneDriveProviders)
        {
        $ProviderKeyString = "OneDrive!"+$UserSID+"!Business1|"+$ProviderKeys.Name.Split("\")[-1]
        $ProviderKeyStringPath = $StoragePolicyRegKey +"\" + $ProviderKeyString

        Set-RegistryValue -RegPath $ProviderKeyStringPath -RegName "02" -RegType DWORD -RegValue $DeleteOneDriveContent
        Set-RegistryValue -RegPath $ProviderKeyStringPath -RegName "128" -RegType DWORD -RegValue $DeleteOneDriveInterval
        }

  • Travis_78's avatar
    Travis_78
    Iron Contributor
    Who would be the right person to talk to Microsoft about this? I would be glad to open an ticket and update this thread.
    • Denise Child's avatar
      Denise Child
      Iron Contributor
      Travis_78 I believe you would need to open it in Azure in your AVD workspace.

      I am investigating our bloated profiles, the one I just found shows 56k files in the appdata\local\isolatedstorage - over 20GB.
      I have 6 more that are over 26GB to verify.
      https://learn.microsoft.com/en-us/dotnet/standard/io/isolated-storage
      • Travis_78's avatar
        Travis_78
        Iron Contributor
        I am dreading trying to work on this through normal channels. I feel like nobody actually understands the problem but maybe some higher level engineers at MSFT. Was hoping someone would chime in and help.
  • Denise Child's avatar
    Denise Child
    Iron Contributor
    I see the same problem with our Profiles using AVD. Some of them are over 30GB. Any help would be great. I am manually cleaning them up when they get too large. Not only the manual work, but the cost in Azure is huge since we have to use Premium. We have ~525 profiles. If we could get them under 1TB it would be a cost savings.
    • Travis_78's avatar
      Travis_78
      Iron Contributor

      Hopefully we can get some more input on this one. Documentation seems light for this kind of configuration.

Resources