簡體   English   中英

對系統硬盤進行碎片整理,僅當是機械盤時

[英]Defrag system hdd only if is mechanical disk

我們需要一些幫助。 在實踐中,我們正在尋找一種方法來啟動主磁盤的碎片整理(碎片整理)(在 Windows“C:”上)僅當它是 HDD 而不是 SSD 我們在 powershell 中閱讀了有關命令但無法編譯(媒體類型)

這個腳本應該適合你:

#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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM