-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDisableStorageSense.ps1
More file actions
46 lines (36 loc) · 1.72 KB
/
DisableStorageSense.ps1
File metadata and controls
46 lines (36 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<#Author : Akash Chawla
# Usage : Disable Storage Sense
#>
#######################################
# Disable Storage Sense #
#######################################
function Set-RegKey($registryPath, $registryKey, $registryValue) {
try {
Write-Host "*** AVD AIB CUSTOMIZER PHASE *** Disable Storage Sense - Setting $registryKey with value $registryValue ***"
New-ItemProperty -Path $registryPath -Name $registryKey -Value $registryValue -PropertyType DWORD -Force -ErrorAction Stop
}
catch {
Write-Host "*** AVD AIB CUSTOMIZER PHASE *** Disable Storage Sense - Cannot add the registry key $registryKey *** : [$($_.Exception.Message)]"
}
}
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
Write-Host "***Starting AVD AIB CUSTOMIZER PHASE: Disable Storage Sense Start - $((Get-Date).ToUniversalTime()) "
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense"
$registryKey = "AllowStorageSenseGlobal"
$registryValue = "0"
$registryPathWin11 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\StorageSense"
IF(!(Test-Path $registryPath)) {
New-Item -Path $registryPath -Force
}
IF(!(Test-Path $registryPathWin11)) {
New-Item -Path $registryPathWin11 -Force
}
Set-RegKey -registryPath $registryPath -registryKey $registryKey -registryValue $registryValue
Set-RegKey -registryPath $registryPathWin11 -registryKey $registryKey -registryValue $registryValue
$stopwatch.Stop()
$elapsedTime = $stopwatch.Elapsed
Write-Host "*** AVD AIB CUSTOMIZER PHASE: Disable Storage Sense - Exit Code: $LASTEXITCODE ***"
Write-Host "*** Ending AVD AIB CUSTOMIZER PHASE: Disable Storage Sense - Time taken: $elapsedTime "
#############
# END #
#############