<< Back to Script Library
Configure Optimize Drives service for FSLogix Disk Compaction
Configures the Optimize Drives service so that FSLogix Disk Compaction will function.
This SBA can be executed manually or used with a trigger pack to automate healing of this misconfiguration. More information is available here:
https://support.controlup.com/docs/trigger-packs
This SBA can be executed manually or used with a trigger pack to automate healing of this misconfiguration. More information is available here:
https://support.controlup.com/docs/trigger-packs
The Script
Copy Script
Copied to clipboard
<#
.SYNOPSIS
Enabled the Optimize Drives service
.DESCRIPTION
Ensures the Optimize Drives service is available to ensure FSLogix disk compaction can function.
.LINK
For more information refer to:
https://www.controlup.com
.LINK
Stay in touch:
https://twitter.com/trententtye
#>
#Get Optimize Drives service meta data
$DefragSvc = Get-Service -Name defragsvc
if ($DefragSvc.StartType -eq "Disabled") {
try {
Set-Service -Name defragsvc -StartupType Automatic
} catch {
Write-Error "Unable to modify the service startup type for the Optimize Drives service"
exit -1
}
}
$DefragSvc = Get-Service -Name defragsvc
if ($DefragSvc.StartType -ne "Disabled") {
Write-Output "Optimize Drives service has been tuned to allow for FSLogix Disk Compaction"
} else {
Write-Error "Unable to modify the service startup type for the Optimize Drives service"
}