-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathW365-EnableScreenCaptureProtection.ps1
More file actions
28 lines (24 loc) · 1.03 KB
/
W365-EnableScreenCaptureProtection.ps1
File metadata and controls
28 lines (24 loc) · 1.03 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
# Define the registry path and key
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"
$keyName = "fEnableScreenCaptureProtection"
$dwordValue = 1
# Create the registry key and set the DWORD value
try {
# Check if the registry path exists, if not create it
if (-not (Test-Path $registryPath)) {
New-Item -Path $registryPath -Force | Out-Null
Write-Host "Created registry path: $registryPath"
}
# Set the registry key with REG_DWORD value
New-ItemProperty -Path $registryPath -Name $keyName -PropertyType DWORD -Value $dwordValue -Force | Out-Null
Write-Host "Registry key '$keyName' set to $dwordValue"
# Verify the value was set correctly
$regValue = Get-ItemProperty -Path $registryPath -Name $keyName
if ($regValue.$keyName -eq $dwordValue) {
Write-Host "Success: The registry key '$keyName' is set to $dwordValue"
} else {
Write-Host "Error: The registry key '$keyName' was not set correctly"
}
} catch {
Write-Host "An error occurred: $_"
}