Skip to content

Instantly share code, notes, and snippets.

@sassdawe
Created June 9, 2026 12:13
Show Gist options
  • Select an option

  • Save sassdawe/15175a972c9592659c92985fe3cda256 to your computer and use it in GitHub Desktop.

Select an option

Save sassdawe/15175a972c9592659c92985fe3cda256 to your computer and use it in GitHub Desktop.
Script to enforce VSCode policies by editing the registry
## source: https://github.com/microsoft/vscode/issues/242922#issuecomment-3928062264
# Create the VS Code policy registry key if it doesn't exist
if (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\VSCode")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\VSCode" -Force -EA SilentlyContinue
}
# Set AllowedExtensions policy - allows Microsoft extensions and approved third-party extensions
$allowedExtensions = @{
# Allow all extensions from trusted publishers
"microsoft" = $true;
"github" = $true;
# Version-locked extensions (specific versions only)
"charliermarsh.ruff" = @("2025.24.0");
"eeyore.yapf" = @("2025.5.107163247");
}
# Convert to JSON string
$allowedExtensionsJson = $allowedExtensions | ConvertTo-Json -Compress
# Set the registry value
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\VSCode" -Name "AllowedExtensions" -PropertyType String -Value $allowedExtensionsJson -Force
# Set UpdateMode to none (prevents update prompts for non-admin users)
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\VSCode" -Name "UpdateMode" -PropertyType String -Value "none" -Force
# Exit with success code
Exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment