Skip to content

Instantly share code, notes, and snippets.

@stesee
Last active December 28, 2024 16:26
Show Gist options
  • Save stesee/5401b8b1a198da20250a3669b1197f00 to your computer and use it in GitHub Desktop.
Save stesee/5401b8b1a198da20250a3669b1197f00 to your computer and use it in GitHub Desktop.

Revisions

  1. stesee revised this gist Dec 10, 2023. 1 changed file with 0 additions and 17 deletions.
    17 changes: 0 additions & 17 deletions DisableTelemetryVS2022.ps1
    Original file line number Diff line number Diff line change
    @@ -22,23 +22,6 @@ Remove-Item -Path "$env:TEMP\VSTelem.Out" -Recurse -Force -ErrorAction SilentlyC
    # Disable telemetry in NuGet
    [Environment]::SetEnvironmentVariable('NUGET_TELEMETRY_OPTOUT', 'true', 'User')

    # Disable telemetry in Visual Studio Code

    # Path to the settings.json file
    $settingsPath = "$env:APPDATA\Code\User\settings.json"

    # Load the current settings
    $settings = Get-Content -Path $settingsPath | ConvertFrom-Json

    # Set the value
    $settings.DOTNET_CLI_TELEMETRY_OPTOUT = '1'

    # Convert the settings back to JSON
    $json = $settings | ConvertTo-Json

    # Write the changes to the settings.json file
    Set-Content -Path $settingsPath -Value $json

    # Disable Telemetry in Visual Studio - Not documented, not proofen to do anything, copied over from https://gist.github.com/stesee/b43e264a79912fe4640fdd85d492e104

    # Define the registry keys
  2. stesee created this gist Dec 10, 2023.
    59 changes: 59 additions & 0 deletions DisableTelemetryVS2022.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    #Requires -RunAsAdministrator

    # Disable telemetry in Visual Studio 2022 - https://learn.microsoft.com/en-us/visualstudio/ide/visual-studio-experience-improvement-program?view=vs-2022
    New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\VSCommon\17.0\SQM" -Name "OptIn" -Value "0" -PropertyType "DWORD" -Force

    # Delete telemetry directories
    Remove-Item -Path "$env:APPDATA\vstelemetry" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\VSApplicationInsights" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:PROGRAMDATA\Microsoft\VSApplicationInsights" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\Microsoft\VSApplicationInsights" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSFaultInfo" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSFeedbackIntelliCodeLogs" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSFeedbackPerfWatsonData" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSFeedbackVSRTCLogs" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSRemoteControl" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSTelem" -Recurse -Force -ErrorAction SilentlyContinue
    Remove-Item -Path "$env:TEMP\VSTelem.Out" -Recurse -Force -ErrorAction SilentlyContinue

    # Disable telemetry in .NET
    [Environment]::SetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1', 'User')

    # Disable telemetry in NuGet
    [Environment]::SetEnvironmentVariable('NUGET_TELEMETRY_OPTOUT', 'true', 'User')

    # Disable telemetry in Visual Studio Code

    # Path to the settings.json file
    $settingsPath = "$env:APPDATA\Code\User\settings.json"

    # Load the current settings
    $settings = Get-Content -Path $settingsPath | ConvertFrom-Json

    # Set the value
    $settings.DOTNET_CLI_TELEMETRY_OPTOUT = '1'

    # Convert the settings back to JSON
    $json = $settings | ConvertTo-Json

    # Write the changes to the settings.json file
    Set-Content -Path $settingsPath -Value $json

    # Disable Telemetry in Visual Studio - Not documented, not proofen to do anything, copied over from https://gist.github.com/stesee/b43e264a79912fe4640fdd85d492e104

    # Define the registry keys
    $VS_POLICIES_KEY = "HKLM:\SOFTWARE\Policies\Microsoft\VisualStudio"
    $VS_POLICIES_FEEDBACK_KEY = "$VS_POLICIES_KEY\Feedback"
    $VS_POLICIES_SQM_KEY = "$VS_POLICIES_KEY\SQM"
    $VS_TELEMETRY_KEY = "HKCU:\Software\Microsoft\VisualStudio\Telemetry"

    # Disable feedback in Visual Studio
    New-ItemProperty -Path $VS_POLICIES_FEEDBACK_KEY -Name "DisableFeedbackDialog" -Value 1 -PropertyType "DWORD" -Force
    New-ItemProperty -Path $VS_POLICIES_FEEDBACK_KEY -Name "DisableEmailInput" -Value 1 -PropertyType "DWORD" -Force
    New-ItemProperty -Path $VS_POLICIES_FEEDBACK_KEY -Name "DisableScreenshotCapture" -Value 1 -PropertyType "DWORD" -Force

    # Disable PerfWatson
    New-ItemProperty -Path $VS_POLICIES_SQM_KEY -Name "OptIn" -Value 0 -PropertyType "DWORD" -Force

    # Disable telemetry
    New-ItemProperty -Path $VS_TELEMETRY_KEY -Name "TurnOffSwitch" -Value 1 -PropertyType "DWORD" -Force