-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin10_set-privacysettings_script.ps1
57 lines (45 loc) · 2.46 KB
/
win10_set-privacysettings_script.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
56
57
# Function to set registry value
function Set-RegistryValue {
param (
[string]$Path,
[string]$Name,
[string]$Value
)
Set-ItemProperty -Path $Path -Name $Name -Value $Value
}
# Function to enable or disable privacy settings
function Set-PrivacySettings {
param (
[string]$State # Accepts 'Enable' or 'Disable'
)
# Set corresponding value based on State
$enableValue = if ($State -eq "Enable") { "Allow" } else { "Deny" }
$telemetryValue = if ($State -eq "Enable") { 3 } else { 1 }
$advertisingIdValue = if ($State -eq "Enable") { 1 } else { 0 }
# Telemetry (Diagnostics & Feedback)
Write-Host "Setting Telemetry to $State..."
Set-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Value $telemetryValue
# Location Services
Write-Host "Setting Location Services to $State..."
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Name "Value" -Value $enableValue
# Advertising ID
Write-Host "Setting Advertising ID to $State..."
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -Value $advertisingIdValue
# Camera Access
Write-Host "Setting Camera Access to $State..."
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam" -Name "Value" -Value $enableValue
# Microphone Access
Write-Host "Setting Microphone Access to $State..."
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone" -Name "Value" -Value $enableValue
# Speech Recognition
Write-Host "Setting Speech Recognition to $State..."
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy" -Name "HasAccepted" -Value $telemetryValue
# Diagnostics (Device history)
Write-Host "Setting Device History to $State..."
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\diagnostics" -Name "Value" -Value $enableValue
Write-Host "Privacy settings updated successfully to $State."
}
# Toggle between Enable or Disable
$choice = Read-Host "Enter 'Enable' to turn on privacy settings or 'Disable' to turn them off"
# Call the function with user input
Set-PrivacySettings -State $choice