Forum Discussion
OneDrive with FSlogix in an AVD environment how to prevent profile bloat
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:
Open an elevated PowerShell prompt and run the following commands:
Set-ItemProperty -Path "HKLM:\SOFTWARE\FSLogix\Apps" -Name VHDCompactDisk -PropertyType DWORD -Value 1 -Force
Restart the computer.
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.
- Micha118835Jan 30, 2023Copper Contributor
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 = 1function 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 $RegPathIf ($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 +"\" + $ProviderKeyStringSet-RegistryValue -RegPath $ProviderKeyStringPath -RegName "02" -RegType DWORD -RegValue $DeleteOneDriveContent
Set-RegistryValue -RegPath $ProviderKeyStringPath -RegName "128" -RegType DWORD -RegValue $DeleteOneDriveInterval
}- Travis_78Feb 02, 2023Iron ContributorWith this script, you say to run the script via the user's login script? Or start menu/startup? Have you used this with success on VHDX / FSlogix users with AVD?
- RahilAKFeb 23, 2023Copper ContributorTravis_78 ----
I read through the entire exchange between you and Micha. We are facing the same issue where we need to dehydrate the onedrive cache. And as you mentioned in the beginning of the conversation, - setting up storage sense would probably not fulfill our need to rehydrate the onedrive cache in fslogix profiles as storage sense runs once a day, and does not make a difference on the profiles which are not attached at the time storage sense runs.
Did you happen to try out the script that was provided by Micha118835, and does that fulfill our requirement?? Could you please give us a feedback if that has been tested.
- Travis_78Feb 01, 2023Iron ContributorThank you for this! I'll give it a shot.