Skip to content

Instantly share code, notes, and snippets.

@stesee
Last active December 14, 2023 09:07
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.
#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 - 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
@bagusnl
Copy link

bagusnl commented Dec 14, 2023

Thank you for the easy-to-use script!
One small problem though, if the key/registry folder doesn't exist, it will just spit out errors. While its easy to fix, adding a check to make sure all registry keys exist before adding the optouts seems like a nice to have kind of thing

Run log
 bagusnl_reg  iex ((New-Object System.Net.WebClient).DownloadString('https://gist.github.com/stesee/5401b8b1a198da20250a3669b1197f00/raw/21bdafefd5a7cd0687427dc34c23d78ca02fbafe/DisableTelemetryVS2022.ps1'))

OptIn        : 0
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VSCommon\17.0\SQM
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VSCommon\17.0
PSChildName  : SQM
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry

New-ItemProperty:
Line |
  34 |  New-ItemProperty -Path $VS_POLICIES_FEEDBACK_KEY -Name "DisableFeedba …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'HKLM:\SOFTWARE\Policies\Microsoft\VisualStudio\Feedback' because it does not exist.
New-ItemProperty:
Line |
  35 |  New-ItemProperty -Path $VS_POLICIES_FEEDBACK_KEY -Name "DisableEmailI …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'HKLM:\SOFTWARE\Policies\Microsoft\VisualStudio\Feedback' because it does not exist.
New-ItemProperty:
Line |
  36 |  New-ItemProperty -Path $VS_POLICIES_FEEDBACK_KEY -Name "DisableScreen …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'HKLM:\SOFTWARE\Policies\Microsoft\VisualStudio\Feedback' because it does not exist.
New-ItemProperty:
Line |
  39 |  New-ItemProperty -Path $VS_POLICIES_SQM_KEY -Name "OptIn" -Value 0 -P …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'HKLM:\SOFTWARE\Policies\Microsoft\VisualStudio\SQM' because it does not exist.
TurnOffSwitch : 1
PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\Telemetry
PSParentPath  : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\VisualStudio
PSChildName   : Telemetry
PSDrive       : HKCU
PSProvider    : Microsoft.PowerShell.Core\Registry

@stesee
Copy link
Author

stesee commented Dec 14, 2023

your right... but.the keys should exist anyway after you installed vs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment