PowerShell Script
If (((Get-PhysicalDisk).MediaType -match "SSD") -or ((Get-WmiObject -Namespace "root/microsoft/windows/storage" -class msft_physicaldisk).mediatype -match "4")) {
Get-ScheduledTask -TaskName "ScheduledDefrag" | Disable-ScheduledTask
}
Steps to Use the Script
1. Open PowerShell
Open PowerShell with administrative rights. Type PowerShell
in the search bar, right-click on Windows PowerShell, and select Run as administrator.
2. Run the Script
Copy the script into a PowerShell file, e.g., DisableDefragForSSD.ps1
, and run it.
.\DisableDefragForSSD.ps1
This script will check for SSDs and disable the scheduled defragmentation task if any are found.
0 Comments