Skip to content

Instantly share code, notes, and snippets.

@Eonasdan
Forked from codebytes/DevMachineSetup.ps1
Last active January 26, 2022 17:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eonasdan/2a7b9c1e4c5eb61271507b3861111682 to your computer and use it in GitHub Desktop.
Save Eonasdan/2a7b9c1e4c5eb61271507b3861111682 to your computer and use it in GitHub Desktop.
DevMachineSetup

From https://chrislayers.com/2021/08/01/scripting-winget/

Run:

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/Eonasdan/2a7b9c1e4c5eb61271507b3861111682/raw/52ae67b4aa148070c9e557035172f86be41d752a/DevMachineSetup.ps1'))"
#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 = "Git.Git" },
@{name = "Docker.DockerDesktop" },
@{name = "Microsoft.dotnet" },
@{name = "GitHub.cli" },
@{name = "JetBrains.Toolbox" },
@{name = "Microsoft.Bicep" },
@{name = "LINQPad.LINQPad.7" },
@{name = "7zip.7zip" },
@{name = "Microsoft.VisualStudio.2022.Community-Preview" },
@{name = "Google.Chrome" },
@{name = "OpenJS.NodeJS" },
@{name = "Notepad++.Notepad++" },
@{name = "Postman.Postman" },
@{name = "VideoLAN.VLC" }
);
Foreach ($app in $apps) {
$listApp = winget list --exact -q $app.name
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
}
else {
winget install --exact --silent $app.name
}
}
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
}
Microsoft.AzureCLI
Microsoft.PowerShell
Microsoft.VisualStudioCode
Git.Git
Docker.DockerDesktop
Microsoft.dotnet
GitHub.cli
JetBrains.Toolbox
Microsoft.Bicep
LINQPad.LINQPad.7
7zip.7zip
Microsoft.VisualStudio.2022.Community-Preview
Google.Chrome
OpenJS.NodeJS
Notepad++.Notepad++
Postman.Postman
VideoLAN.VLC
Microsoft.SQLServer.2019.Developer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment