Forked from Celoxocis/Powershell – Disable Drive Indexing
Last active
January 25, 2023 15:35
-
-
Save john-clark/4b7dc678843bb6df2958caa98c373010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Disable-DriveIndexing { | |
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-DriveIndexing "C:" | |
function Enable-DriveIndexing { | |
Param($Drive) | |
$obj = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter='$Drive'" | |
$indexing = $obj.IndexingEnabled | |
if("$indexing" -eq $False){ | |
write-host "Enbaling indexing of drive $Drive" | |
$obj | Set-WmiInstance -Arguments @{IndexingEnabled=$True} | Out-Null | |
} | |
} | |
#Use: Enable-DriveIndexing "C:" | |
function Enable-DriveCompression { | |
Param($Drive) | |
$obj = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter='$Drive'" | |
$indexing = $obj.IsCompressionEnabled | |
if("$indexing" -eq $False){ | |
write-host "Enabling Compression of drive $Drive" | |
$obj | Set-WmiInstance -Arguments @{IsCompressionEnabled=$True} | Out-Null | |
} | |
} | |
#Use: Enable-DriveCompression "C:" | |
function Disable-DriveCompression { | |
Param($Drive) | |
$obj = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter='$Drive'" | |
$indexing = $obj.IsCompressionEnabled | |
if("$indexing" -eq $True){ | |
write-host "Disabling indexing of drive $Drive" | |
$obj | Set-WmiInstance -Arguments @{IsCompressionEnabled=$False} | Out-Null | |
} | |
} | |
#Use: Enable-DriveCompression "C:" | |
<# | |
add more like this use this script | |
echo $getwritableproperties | Select-String Compress | |
*> | |
$getwritableproperties = Get-WmiObject -List -Recurse | Select -Expand Properties | Where-Object { $_ | Select -Expand Qualifiers | Where-Object { $_.Name -eq "Write" } } | Select Origin,Name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment