-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathW365-Hide-Shutdown.ps1
25 lines (21 loc) · 1009 Bytes
/
W365-Hide-Shutdown.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
# Define the path to the registry subkey
$subkeyPath = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Start\HideShutDown"
# Define the name of the DWORD value to check and set
$dwordName = "value"
# Check if the registry subkey exists
if (-not (Test-Path $subkeyPath)) {
# Create the registry subkey if it doesn't exist
New-Item -Path $subkeyPath -Force
Write-Output "Registry subkey '$subkeyPath' created."
}
# Check if the DWORD value exists
$dwordExists = Get-ItemProperty -Path $subkeyPath -Name $dwordName -ErrorAction SilentlyContinue
if ($null -ne $dwordExists) {
# Set the DWORD value to 1
Set-ItemProperty -Path $subkeyPath -Name $dwordName -Value 1 -Type DWord
Write-Output "Registry DWORD value '$dwordName' set to 1 in '$subkeyPath'."
} else {
# Create the DWORD value and set it to 0
New-ItemProperty -Path $subkeyPath -Name $dwordName -Value 1 -PropertyType DWord
Write-Output "Registry DWORD value '$dwordName' created and set to 1 in '$subkeyPath'."
}