-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScreenCaptureProtection.ps1
55 lines (44 loc) · 1.87 KB
/
ScreenCaptureProtection.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<#Author : Akash Chawla
# Usage : Screen capture protection
#>
#######################################
# Screen capture protection #
#######################################
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[string] $BlockOption
)
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
Write-Host '*** AVD AIB CUSTOMIZER PHASE: Screen capture protection ***'
$screenCaptureRegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"
$screenCaptureRegistryName = "fEnableScreenCaptureProtect"
# by default, block both client and server - registry value 2 refers to block both client and server
$screenCaptureRegistryValue = "2"
if(($PSBoundParameters.ContainsKey('BlockOption'))) {
if($BlockOption -eq "BlockClient") {
# registry value 1 refers to block only client
$screenCaptureRegistryValue = "1"
}
else {
$screenCaptureRegistryValue = "2"
}
}
IF(!(Test-Path $screenCaptureRegistryPath)) {
New-Item -Path $screenCaptureRegistryPath -Force | Out-Null
}
try {
Write-Host "*** AVD AIB CUSTOMIZER PHASE *** Screen capture protection - Setting $screenCaptureRegistryName with value $screenCaptureRegistryValue ***"
New-ItemProperty -Path $screenCaptureRegistryPath -Name $screenCaptureRegistryName -Value $screenCaptureRegistryValue -PropertyType DWORD -Force | Out-Null
}
catch {
Write-Host "*** AVD AIB CUSTOMIZER PHASE: Screen capture protection - Cannot add the registry key *** : [$($_.Exception.Message)]"
Write-Host "Message: [$($_.Exception.Message)"]
}
$stopwatch.Stop()
$elapsedTime = $stopwatch.Elapsed
Write-Host "*** AVD AIB CUSTOMIZER PHASE: Screen capture protection - Exit Code: $LASTEXITCODE ***"
Write-Host "*** AVD AIB CUSTOMIZER PHASE: Screen capture protection - Time taken: $elapsedTime ***"
#############
# END #
#############