[英]Defrag system hdd only if is mechanical disk
we needed some help.我们需要一些帮助。 in practice we were looking for a method to start the defremmentation (defrag) of the primary disk (on windows "C:") only if it is a HDD and not an SSD we read about the command in powershell but can't compile (mediaType)
在实践中,我们正在寻找一种方法来启动主磁盘的碎片整理(碎片整理)(在 Windows“C:”上)仅当它是 HDD 而不是 SSD 我们在 powershell 中阅读了有关命令但无法编译(媒体类型)
This script should work for you:这个脚本应该适合你:
#Get friendly name of the C drive
$name = (get-partition -DriveLetter C | get-disk).FriendlyName
#Use friendly name to determine drive type
$mediatype = (Get-PhysicalDisk -FriendlyName $name).MediaType
#Defragment drive if drive type is HDD
if ($mediatype -eq "HDD")
{
Optimize-Volume -DriveLetter C
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.