1

我正在尝试编写一个 powershell 脚本,该脚本将在某些驱动器上禁用索引,但在其他驱动器上保持激活状态(例如:C:)。

以前有人做过吗?

谢谢

4

1 回答 1

0

试试这个,(未测试):

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:"
于 2013-01-25T13:34:57.813 回答