我正在尝试编写一个 powershell 脚本,该脚本将在某些驱动器上禁用索引,但在其他驱动器上保持激活状态(例如:C:)。
以前有人做过吗?
谢谢
试试这个,(未测试):
function Disable-Indexing{
Param($Drive)
$obj = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter='$Drive'"
$indexing = $obj.IndexingEnabled
if("$indexing" -eq $True){
write-host "Disabling indexing of drive $Drive"
$obj | Set-WmiInstance -Arguments @{IndexingEnabled=$False} | Out-Null
}
}
use:
disable-indexing "c:"