I den digitala tidsåldern har datasekretess och datasäkerhet blivit av största vikt. I takt med att Windows 10 har blivit allt populärare har även oron för dess funktioner för datainsamling ökat. För IT-proffs och tjänsteleverantörer (MSP) är det avgörande att förstå och kontrollera dessa funktioner. Den här artikeln handlar om ett PowerShell-skript som är utformat för att aktivera eller inaktivera Windows 10:s datainsamlingsfunktioner.
Bakgrund
Windows 10, liksom många andra moderna operativsystem, har inbyggda funktioner för telemetri och datainsamling. Dessa är avsedda att förbättra användarupplevelsen genom att samla in data om användningsmönster, fel och mer. Men av olika skäl, t.ex. integritetsskäl och regelefterlevnad, behöver IT-proffs och MSP:er ofta kontrollera dessa funktioner. Det medföljande skriptet erbjuder ett strömlinjeformat sätt att hantera dessa inställningar.
Manus
<#Requires -Version 5.1 <# .SYNOPSIS Enables or Disabled Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .DESCRIPTION Enables or Disabled Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE No Params needed to Disable Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE -Enable Enables Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE PS C:> Set-Windows10KeyLogger.ps1 Disables Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE PS C:> Set-Windows10KeyLogger.ps1 -Enable Enables Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .OUTPUTS None .NOTES Minimum OS Architecture Supported: Windows 10 Release Notes: Initial Release By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use. Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA). .COMPONENT OSSecurity #> [CmdletBinding()] param ( [Parameter()] [Switch] $Enable ) begin { function Test-IsElevated { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object System.Security.Principal.WindowsPrincipal($id) if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Output $true } else { Write-Output $false } } function Set-ItemProp { param ( $Path, $Name, $Value, [ValidateSet('DWord', 'QWord', 'String', 'ExpandedString', 'Binary', 'MultiString', 'Unknown')] $PropertyType = 'DWord' ) New-Item -Path $Path -Force | Out-Null if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) { Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false | Out-Null } else { New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false | Out-Null } } $Type = "DWORD" } process { if (-not (Test-IsElevated)) { Write-Error -Message "Access Denied. Please run with Administrator privileges." exit 1 } $Value = if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { 1 }else { 0 } try { @( # Linguistic Data Collection [PSCustomObject]@{ Path = "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesTextInput" Name = "AllowLinguisticDataCollection" } # Advertising ID [PSCustomObject]@{ Path = "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionAdvertisingInfo" Name = "Enabled" } # Telemetry [PSCustomObject]@{ Path = "HKLM:SOFTWAREPoliciesMicrosoftWindowsDataCollection" Name = "AllowTelemetry" } ) | ForEach-Object { Set-ItemProp -Path $_.Path -Name $_.Name -Value $Value -PropertyType $Type Write-Host "$($_.Path)$($_.Name) set to $(Get-ItemPropertyValue -Path $_.Path -Name $_.Name)" } if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { Write-Host "Enabling DiagTrack Services" Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service } else { Write-Host "Disabling DiagTrack Services" Get-Service -Name DiagTrack | Set-Service -StartupType Disabled | Stop-Service } Write-Host "DiagTrack Service status: $(Get-Service -Name DiagTrack | Select-Object -Property Status -ExpandProperty Status)" Write-Host "DiagTrack Service is set to: $(Get-Service -Name dmwappushservice | Select-Object -Property StartType -ExpandProperty StartType)" if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { Get-Service -Name dmwappushservice | Set-Service -StartupType Manual } else { Get-Service -Name dmwappushservice | Set-Service -StartupType Disabled | Stop-Service } Write-Host "dmwappushservice Service status: $(Get-Service -Name dmwappushservice | Select-Object -Property Status -ExpandProperty Status)" Write-Host "dmwappushservice Service is set to: $(Get-Service -Name dmwappushservice | Select-Object -Property StartType -ExpandProperty StartType)" $tasks = "SmartScreenSpecific", "ProgramDataUpdater", "Microsoft Compatibility Appraiser", "AitAgent", "Proxy", "Consolidator", "KernelCeipTask", "BthSQM", "CreateObjectTask", "WinSAT", #"Microsoft-Windows-DiskDiagnosticDataCollector", # This is disabled by default "GatherNetworkInfo", "FamilySafetyMonitor", "FamilySafetyRefresh", "SQM data sender", "OfficeTelemetryAgentFallBack", "OfficeTelemetryAgentLogOn" if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { Write-Host "Enabling telemetry scheduled tasks" $tasks | ForEach-Object { Write-Host "Enabling $_ Scheduled Task" # Note: ErrorAction set to SilentlyContinue so as to skip over any missing tasks. Enable-ScheduledTask will still error if it can't be enabled. Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Enable-ScheduledTask $State = Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Select-Object State -ExpandProperty State Write-Host "Scheduled Task: $_ is $State" } } else { Write-Host "Disabling telemetry scheduled tasks" $tasks | ForEach-Object { Write-Host "Disabling $_ Scheduled Task" # Note: ErrorAction set to SilentlyContinue so as to skip over any missing tasks. Disable-ScheduledTask will still error if it can't be disabled. Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Disable-ScheduledTask $State = Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Select-Object State -ExpandProperty State Write-Host "Scheduled Task: $_ is $State" } } } catch { Write-Error $_ exit 1 } gpupdate.exe /force exit 0 } end {}
|
#Requires -Version 5.1 <# .SYNOPSIS Enables or Disabled Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .DESCRIPTION Enables or Disabled Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE No Params needed to Disable Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE -Enable Enables Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE PS C:> Set-Windows10KeyLogger.ps1 Disables Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .EXAMPLE PS C:> Set-Windows10KeyLogger.ps1 -Enable Enables Windows 10 Linguistic Data Collection, Advertising ID, and Telemetry .OUTPUTS None .NOTES Minimum OS Architecture Supported: Windows 10 Release Notes: Initial Release By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use. Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA). .COMPONENT OSSecurity #> [CmdletBinding()] param ( [Parameter()] [Switch] $Enable ) begin { function Test-IsElevated { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object System.Security.Principal.WindowsPrincipal($id) if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Output $true } else { Write-Output $false } } function Set-ItemProp { param ( $Path, $Name, $Value, [ValidateSet('DWord', 'QWord', 'String', 'ExpandedString', 'Binary', 'MultiString', 'Unknown')] $PropertyType = 'DWord' ) New-Item -Path $Path -Force | Out-Null if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) { Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false | Out-Null } else { New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false | Out-Null } } $Type = "DWORD" } process { if (-not (Test-IsElevated)) { Write-Error -Message "Access Denied. Please run with Administrator privileges." exit 1 } $Value = if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { 1 }else { 0 } try { @( # Linguistic Data Collection [PSCustomObject]@{ Path = "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesTextInput" Name = "AllowLinguisticDataCollection" } # Advertising ID [PSCustomObject]@{ Path = "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionAdvertisingInfo" Name = "Enabled" } # Telemetry [PSCustomObject]@{ Path = "HKLM:SOFTWAREPoliciesMicrosoftWindowsDataCollection" Name = "AllowTelemetry" } ) | ForEach-Object { Set-ItemProp -Path $_.Path -Name $_.Name -Value $Value -PropertyType $Type Write-Host "$($_.Path)$($_.Name) set to $(Get-ItemPropertyValue -Path $_.Path -Name $_.Name)" } if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { Write-Host "Enabling DiagTrack Services" Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service } else { Write-Host "Disabling DiagTrack Services" Get-Service -Name DiagTrack | Set-Service -StartupType Disabled | Stop-Service } Write-Host "DiagTrack Service status: $(Get-Service -Name DiagTrack | Select-Object -Property Status -ExpandProperty Status)" Write-Host "DiagTrack Service is set to: $(Get-Service -Name dmwappushservice | Select-Object -Property StartType -ExpandProperty StartType)" if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { Get-Service -Name dmwappushservice | Set-Service -StartupType Manual } else { Get-Service -Name dmwappushservice | Set-Service -StartupType Disabled | Stop-Service } Write-Host "dmwappushservice Service status: $(Get-Service -Name dmwappushservice | Select-Object -Property Status -ExpandProperty Status)" Write-Host "dmwappushservice Service is set to: $(Get-Service -Name dmwappushservice | Select-Object -Property StartType -ExpandProperty StartType)" $tasks = "SmartScreenSpecific", "ProgramDataUpdater", "Microsoft Compatibility Appraiser", "AitAgent", "Proxy", "Consolidator", "KernelCeipTask", "BthSQM", "CreateObjectTask", "WinSAT", #"Microsoft-Windows-DiskDiagnosticDataCollector", # This is disabled by default "GatherNetworkInfo", "FamilySafetyMonitor", "FamilySafetyRefresh", "SQM data sender", "OfficeTelemetryAgentFallBack", "OfficeTelemetryAgentLogOn" if ($PSBoundParameters.ContainsKey("Enable") -and $Enable) { Write-Host "Enabling telemetry scheduled tasks" $tasks | ForEach-Object { Write-Host "Enabling $_ Scheduled Task" # Note: ErrorAction set to SilentlyContinue so as to skip over any missing tasks. Enable-ScheduledTask will still error if it can't be enabled. Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Enable-ScheduledTask $State = Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Select-Object State -ExpandProperty State Write-Host "Scheduled Task: $_ is $State" } } else { Write-Host "Disabling telemetry scheduled tasks" $tasks | ForEach-Object { Write-Host "Disabling $_ Scheduled Task" # Note: ErrorAction set to SilentlyContinue so as to skip over any missing tasks. Disable-ScheduledTask will still error if it can't be disabled. Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Disable-ScheduledTask $State = Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue | Select-Object State -ExpandProperty State Write-Host "Scheduled Task: $_ is $State" } } } catch { Write-Error $_ exit 1 } gpupdate.exe /force exit 0 } end {}
Få tillgång till över 300 skript i NinjaOne Dojo
Detaljerad uppdelning
Skriptet är en PowerShell-cmdlet som växlar Windows 10:s språkliga datainsamling, reklam-ID och telemetri. Här följer en steg-för-steg-genomgång:
- Förkunskapskrav: Skriptet kräver PowerShell version 5.1.
- Parametrar: Skriptet accepterar en valfri -Enable-omkopplare. Om detta anges aktiveras datainsamlingsfunktionerna, annars inaktiveras de.
- Funktioner:
- Test-IsElevated: Kontrollerar om skriptet körs med administratörsbehörighet.
- Set-ItemProp: Anger eller skapar ett värde för en registernyckel.
- Process:
- Först kontrollerar skriptet om du har administratörsbehörighet. Om den inte är närvarande avslutas den.
- Därefter avgörs om funktionerna ska aktiveras eller inaktiveras baserat på omkopplaren -Enable.
- Skriptet ändrar specifika registernycklar som motsvarar den språkliga datainsamlingen, reklam-ID och telemetri.
- Den hanterar även tjänsterna DiagTrack och dmwappushservice, som är relaterade till telemetri.
- Slutligen växlar den mellan olika telemetri-relaterade schemalagda uppgifter.
- Verkställighet: Skriptet avslutas med att tvinga fram en uppdatering av grupprinciper.
Potentiella användningsområden
Tänk dig en MSP som hanterar IT för en vårdgivare. På grund av HIPAA-reglerna måste de säkerställa minimalt dataläckage. Med hjälp av detta skript kan MSP snabbt inaktivera alla funktioner för datainsamling på alla Windows 10-maskiner i nätverket, vilket säkerställer efterlevnad och förbättrar patientdataskyddet.
Jämförelser
Det finns GUI-baserade verktyg och manuella metoder för att växla dessa inställningar, men det här skriptet erbjuder en mer effektiv, repeterbar och skalbar lösning. Manuella metoder kan vara tidskrävande och felkänsliga, särskilt om de används på flera maskiner. GUI-verktyg kanske inte erbjuder den granularitet eller automatiseringsmöjligheter som ett PowerShell-skript gör.
Vanliga frågor
- Kan jag köra skriptet på äldre Windows-versioner?
Nej, det här skriptet är särskilt utformat för Windows 10. - Behöver jag administratörsbehörighet för att köra skriptet?
Ja, skriptet kräver administratörsrättigheter för att ändra registernycklar och hantera tjänster.
Konsekvenser
Genom att använda detta skript kan dataskyddet förbättras avsevärt, särskilt i sektorer med strikta regler. Om du inaktiverar vissa funktioner kan det dock begränsa vissa funktioner eller feedbackmekanismer i Windows 10. IT-proffs bör väga fördelarna mot potentiella begränsningar.
Rekommendationer
- Säkerhetskopiera alltid registerinställningarna innan du gör ändringar.
- Testa skriptet i en kontrollerad miljö innan du distribuerar det brett.
- Granska och uppdatera regelbundet skripten för att ta hänsyn till eventuella ändringar i framtida Windows 10-uppdateringar.
Avslutande tankar
För IT-proffs och MSP:er kan verktyg som NinjaOne vara ovärderliga för att hantera och övervaka IT-miljöer. I kombination med skript som det diskuterade kan de säkerställa en säker, kompatibel och effektiv IT-infrastruktur. I takt med att funktionerna för datainsamling i Windows 10 utvecklas är det viktigt att ha en robust verktygslåda och kunskapsbas för att lyckas.