forked from achawla5/PSScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisableStorageSense.ps1
35 lines (28 loc) · 1.2 KB
/
DisableStorageSense.ps1
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
<#Author : Akash Chawla
# Usage : Disable Storage Sense
#>
#######################################
# Disable Storage Sense #
#######################################
$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"
IF(!(Test-Path $registryPath)) {
New-Item -Path $registryPath -Force
}
try {
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)]"
Write-Host "Message: [$($_.Exception.Message)"]
}
$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 #
#############