Na era digital, a privacidade e a segurança dos dados tornaram-se primordiais. Com o aumento da popularidade do Windows 10, também aumentaram as preocupações com seus recursos de coleta de dados. Para os profissionais de TI e os provedores de serviços gerenciados (MSPs), é fundamental compreender e controlar esses recursos. Este artigo se aprofunda em um script do PowerShell projetado para ativar ou desativar os recursos de coleta de dados do Windows 10.
Histórico
O Windows 10, como muitos sistemas operacionais modernos, tem recursos integrados de telemetria e coleta de dados. Eles têm o objetivo de melhorar a experiência do usuário coletando dados sobre padrões de uso, erros e muito mais. No entanto, por vários motivos, incluindo preocupações com a privacidade e conformidade normativa, os profissionais de TI e os MSPs geralmente precisam controlar esses recursos. O script fornecido oferece uma maneira simplificada de gerenciar essas configurações.
O roteiro
#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 {}
Acesse mais de 300 scripts no NinjaOne Dojo
Detalhamento
O script é um cmdlet do PowerShell que alterna a coleta de dados linguísticos, a ID de publicidade e a telemetria do Windows 10. Aqui está um detalhamento passo a passo:
- Pré-requisitos: O script requer a versão 5.1 do PowerShell.
- Parâmetros: O script aceita uma chave opcional -Enable. Se fornecido, ele ativa os recursos de coleta de dados; caso contrário, ele os desativa.
- Funções:
- Test-IsElevated: Verifica se o script está sendo executado com privilégios de administrador.
- Set-ItemProp: Define ou cria um valor de chave de registro.
- Processo:
- Primeiro, o script verifica se há privilégios de administrador. Se não estiver presente, ele é encerrado.
- Em seguida, ele determina se deve ativar ou desativar os recursos com base na chave -Enable.
- O script modifica chaves de registro específicas correspondentes à coleta de dados linguísticos, à ID de publicidade e à telemetria.
- Ele também gerencia os serviços DiagTrack e dmwappushservice, que estão relacionados à telemetria.
- Por fim, ele alterna várias tarefas agendadas relacionadas à telemetria.
- Execução: O script é concluído forçando uma atualização da política de grupo.
Casos de uso em potencial
Imagine um MSP gerenciando a TI de um provedor de serviços de saúde. Devido às normas da HIPAA, eles precisam garantir o mínimo de vazamento de dados. Usando esse script, o MSP pode desativar rapidamente todos os recursos de coleta de dados em todos os computadores com Windows 10 na rede, garantindo a conformidade e aumentando a privacidade dos dados dos pacientes.
Comparações
Embora existam ferramentas baseadas em GUI e métodos manuais para alternar essas configurações, esse script oferece uma solução mais eficiente, repetível e dimensionável. Os métodos manuais podem ser demorados e propensos a erros, especialmente em várias máquinas. As ferramentas de GUI podem não oferecer a granularidade ou os recursos de automação que um script do PowerShell oferece.
Implicações
O uso desse script pode aumentar significativamente a privacidade dos dados, especialmente em setores com normas rígidas. No entanto, a desativação de alguns recursos pode limitar determinadas funcionalidades ou mecanismos de feedback no Windows 10. Os profissionais de TI devem pesar os benefícios em relação às possíveis limitações.
Recomendações
- Sempre faça backup das configurações do registro antes de fazer alterações.
- Teste o script em um ambiente controlado antes de implementá-lo amplamente.
- Revise e atualize regularmente os scripts para acomodar quaisquer alterações em futuras atualizações do Windows 10.
Considerações finais
Para profissionais de TI e MSPs, ferramentas como o NinjaOne podem ser valiosas para gerenciar e monitorar ambientes de TI. Quando combinados com scripts como o discutido, eles podem garantir uma infraestrutura de TI segura, compatível e eficiente. À medida que os recursos de coleta de dados do Windows 10 evoluem, ter um conjunto robusto de ferramentas e uma base de conhecimento será essencial para o sucesso.