Nell’era digitale, la privacy e la sicurezza dei dati sono diventate fondamentali. Con l’aumento della popolarità di Windows 10, sono cresciute anche le preoccupazioni per le sue funzionalità di raccolta dati. Per i professionisti IT e i provider di servizi gestiti (MSP), la comprensione e il controllo di queste funzionalità sono fondamentali. Questo articolo analizza uno script PowerShell progettato per abilitare o disabilitare la raccolta dati di Windows 10.
Background
Windows 10, come molti sistemi operativi moderni, dispone di funzionalità integrate di telemetria e raccolta dati. Queste hanno lo scopo di migliorare l’esperienza dell’utente raccogliendo dati sui modelli di utilizzo, sugli errori e altro ancora. Tuttavia, per vari motivi, tra cui le preoccupazioni per la privacy e la conformità alle normative, i professionisti IT e gli MSP hanno spesso bisogno di controllare queste funzionalità e di abilitare o disabilitare la raccolta dati di Windows. Lo script fornito offre un modo semplificato per gestire queste impostazioni.
Lo script per disabilitare la raccolta dati di Windows 10
#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 (c) 2023 NinjaOne 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/it/condizioni-utilizzo 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 {}
Accedi a oltre 700 script nel Dojo di NinjaOne
Analisi dettagliata
Lo script PowerShell serve per abilitare o disabilitare la raccolta dati di Windows e agisce sui dati linguistici, degli ID pubblicitari e della telemetria di Windows 10. Ecco una spiegazione passo per passo:
- Prerequisiti: Lo script per disabilitare la raccolta dati di Windows richiede la versione 5.1 di PowerShell.
- Parametri: Lo script per disabilitare la raccolta dati di Windows accetta il parametro opzionale -Enable. Se fornito, abilita le funzioni di raccolta dei dati, altrimenti le disabilita.
- Funzioni:
- Test-IsElevated: Controlla se lo script per disabilitare la raccolta dati di Windows è in esecuzione con privilegi di amministratore.
- Set-ItemProp: Imposta o crea il valore di una chiave di registro.
- Process:
- Innanzitutto, lo script per disabilitare la raccolta dati di Windows verifica la presenza di privilegi di amministratore. Se non ci sono, lo script termina.
- Successivamente, abilita o disabilita le funzionalità in base al parametro -Enable.
- Lo script per disabilitare la raccolta dati di Windows modifica le chiavi di registro specifiche corrispondenti alla raccolta dei dati linguistici, degli ID pubblicitari e della telemetria.
- Gestisce anche i servizi DiagTrack e dmwappushservice, che sono correlati alla telemetria.
- Infine, permette di abilitare o disabilitare varie attività programmate relative alla telemetria.
- Esecuzione: Lo script per disabilitare la raccolta dati di Windows si conclude forzando l’aggiornamento dei criteri di gruppo.
Situazioni d’uso potenziali
Immagina un MSP che gestisce l’IT per un’azienda sanitaria. A causa delle normative HIPAA, deve garantire una perdita minima di dati. Utilizzando questo script, l’MSP può disabilitare la raccolta dati di Windows in modo rapido e su tutti i computer Windows 10 della rete, garantendo la conformità e migliorando la privacy dei dati dei pazienti.
Confronti
Sebbene esistano strumenti basati su GUI e metodi manuali per modificare abilitare o disabilitare la raccolta dati di Windows 10, questo script offre una soluzione più efficiente, ripetibile e scalabile. I metodi manuali possono richiedere molto tempo ed essere soggetti a errori, soprattutto quando devono essere utilizzati su più macchine. Gli strumenti dell’interfaccia grafica potrebbero non offrire la granularità o le capacità di automazione di uno script PowerShell.
Domande frequenti
- È possibile eseguire questo script su versioni precedenti di Windows?
No, questo script è stato progettato specificamente per Windows 10. - È necessario disporre dei privilegi di amministratore per eseguire lo script?
Sì, lo script per disabilitare la raccolta dati di Windows richiede i diritti di amministratore per modificare le chiavi di registro e gestire i servizi.
Implicazioni
L’utilizzo di questo script per disabilitare la raccolta dati di Windows può migliorare in modo significativo la privacy dei dati, soprattutto in settori con normative severe. Tuttavia, disabilitare alcune funzionalità potrebbe limitare operazioni o meccanismi di feedback in Windows 10. I professionisti IT devono valutare i vantaggi in rapporto con le potenziali limitazioni.
Raccomandazioni
- Esegui sempre un backup delle impostazioni del registro prima di apportare modifiche.
- Testa lo script per disabilitare la raccolta dati di Windows in un ambiente controllato prima di distribuirlo su larga scala.
- Controlla e aggiorna regolarmente gli script per adattarli alle eventuali modifiche causate dagli aggiornamenti di Windows 10.
Considerazioni finali
Per i professionisti IT e gli MSP, strumenti come NinjaOne possono essere preziosi per la gestione e il monitoraggio degli ambienti IT. Se combinati con script come quello descritto, possono garantire un’infrastruttura IT sicura, conforme ed efficiente. Con l’evolversi delle funzionalità di raccolta dati di Windows 10, disporre di un solido set di strumenti e di una knowledge base sarà essenziale per il successo.