Friday, 30 July 2021

Compacting user profile disks (UPD) on a RDS Broker / host setup

 UPD by default can grow up to 20GB,  this will happen automatically over time as the users add more data and generates more trash data.

This will never clean down though and can lead to the system looking larger then it actually is.

This is a good script to run to clean down the white space within the UPD


#FILE
$VHDXPaths = @(
    '\\SERVER\FSLogix',
    '\\SERVER\ProfileDisks'
)

$VHDXExclusions = @(
    'UVHD-template.vhdx'
)

Foreach ($Path in $VHDXPaths){
    $AllUPDs = Get-ChildItem $Path -Recurse -Filter *.vhdx | Where-Object {$VHDXExclusions -NotContains $_.name} | Select-Object -ExpandProperty fullname

    foreach ($UPD in $AllUPDs){
        NEW-ITEM -Name compact.txt -ItemType file -force | OUT-NULL
        ADD-CONTENT -Path compact.txt "select vdisk file= $UPD"
        ADD-CONTENT -Path compact.txt "compact vdisk"
        DISKPART /S compact.TXT
    }
}

#EOF


PowerShell/Compact-UPDs.ps1 at master · andy2002a/PowerShell · GitHub

No comments:

Post a Comment