Skip to content

Instantly share code, notes, and snippets.

@codebytes
Last active May 5, 2025 14:22
Show Gist options
  • Select an option

  • Save codebytes/29bf18015f6e93fca9421df73c6e512c to your computer and use it in GitHub Desktop.

Select an option

Save codebytes/29bf18015f6e93fca9421df73c6e512c to your computer and use it in GitHub Desktop.
DevMachineSetup
#Install WinGet
#Based on this gist: https://gist.github.com/crutkas/6c2096eae387e544bd05cde246f23901
$hasPackageManager = Get-AppPackage -name 'Microsoft.DesktopAppInstaller'
if (!$hasPackageManager -or [version]$hasPackageManager.Version -lt [version]"1.10.0.0") {
"Installing winget Dependencies"
Add-AppxPackage -Path 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
$releases_url = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$releases = Invoke-RestMethod -uri $releases_url
$latestRelease = $releases.assets | Where { $_.browser_download_url.EndsWith('msixbundle') } | Select -First 1
"Installing winget from $($latestRelease.browser_download_url)"
Add-AppxPackage -Path $latestRelease.browser_download_url
}
else {
"winget already installed"
}
#Configure WinGet
Write-Output "Configuring winget"
#winget config path from: https://github.com/microsoft/winget-cli/blob/master/doc/Settings.md#file-location
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json";
$settingsJson =
@"
{
// For documentation on these settings, see: https://aka.ms/winget-settings
"experimentalFeatures": {
"experimentalMSStore": true,
}
}
"@;
$settingsJson | Out-File $settingsPath -Encoding utf8
#Install New apps
Write-Output "Installing Apps"
$apps = @(
@{name = "Microsoft.AzureCLI" },
@{name = "Microsoft.PowerShell" },
@{name = "Microsoft.VisualStudioCode" },
@{name = "Microsoft.WindowsTerminal"; source = "msstore" },
@{name = "Microsoft.Azure.StorageExplorer" },
@{name = "Microsoft.PowerToys" },
@{name = "Git.Git" },
@{name = "Docker.DockerDesktop" },
@{name = "Microsoft.DotNet.SDK.6" },
@{name = "Microsoft.DotNet.SDK.7" },
@{name = "GitHub.cli" },
@{name = "Canonical.Ubuntu.2204" },
@{name = "GitHub.GitHubDesktop" },
@{name = "JanDeDobbeleer.OhMyPosh" },
@{name = "Python.Python.3.10" },
@{name = "Node.js" },
@{name = "Visual Studio Enterprise 2022" }
);
Foreach ($app in $apps) {
$listApp = winget list --exact -q $app.name --accept-source-agreements
if (![String]::Join("", $listApp).Contains($app.name)) {
Write-host "Installing:" $app.name
if ($app.source -ne $null) {
winget install --exact --silent $app.name --source $app.source --accept-package-agreements
}
else {
winget install --exact --silent $app.name --accept-package-agreements
}
}
else {
Write-host "Skipping Install of " $app.name
}
}
#Remove Apps
Write-Output "Removing Apps"
$apps = "*3DPrint*", "Microsoft.MixedReality.Portal"
Foreach ($app in $apps)
{
Write-host "Uninstalling:" $app
Get-AppxPackage -allusers $app | Remove-AppxPackage
}
#Setup WSL
wsl --install
@Dragod
Copy link
Copy Markdown

Dragod commented Oct 28, 2021

Edition Windows 10 Home
Version 21H1
Installed on ‎10/‎27/‎2021
OS build 19043.928
Experience Windows Feature Experience Pack 120.2212.551.0

Trying to use this script on a Windows 10 Vm but it stops at "Installing apps" then nothing happens, no errors, the script just hang there forever

Capture

This is a weird one, I somewaht made it work on my laptop but still do not work on my Win10 VM.

Edit: Just found that if I install Windows terminal it all work like a charm...but no idea why...doesn't make any sense

@PavelH76
Copy link
Copy Markdown

Hi, i run in to same problem. Problem is with msstore. With first run msstore need accept eula. this can be done with --accept-source-agreements [https://githubmemory.com/repo/microsoft/winget-cli/issues/1559]

@codebytes
Copy link
Copy Markdown
Author

I updated the script to resolve the issue. I added the relevant -accept-package-agreements and --accept-source-agreements flags.

@codebytes
Copy link
Copy Markdown
Author

Wipe machine
run all updates, reboot
open admin powershell/terminal

iex ((New-Object System.Net.WebClient).DownloadString('https://gist.github.com/codebytes/29bf18015f6e93fca9421df73c6e512c/raw/a888dea57de571a985297ea9c14f77bb65de920f/DevMachineSetup.ps1'))

reboot.

@Dragod
Copy link
Copy Markdown

Dragod commented Mar 28, 2023

Thanks for the updates

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