Last active
March 20, 2023 01:10
-
-
Save KZeronimo/724a4fc6f01c2e4148dc79fe21e85ed0 to your computer and use it in GitHub Desktop.
Winget based Boxstarter Script - Raspi Full - Windows 10/11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set TLS 1.2 | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
# Import Choco Install-* | |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force | |
# Set up choco cache location to work around Boxstarter Issue 241 | |
$chocoCache = (Join-Path ([Environment]::GetEnvironmentVariable("LocalAppData")) "Temp\ChocoCache") | |
New-Item -Path $chocoCache -ItemType directory -Force | |
# Remove *.tmp from the choco cache directory so the ad-hoc package installs using Install-ChocolateyPackage behave idempotently - this is a hack | |
Remove-Item -Path (Join-Path $chocoCache '*.tmp') -Recurse -Force | |
# Get Post Build Content | |
Write-BoxstarterMessage "Getting post build content" | |
$path = "C:\_PostBuildContent" | |
$answersPath = "C:\Windows\Temp\User_Answers.json" | |
if (Test-Path -Path $path) { | |
Remove-Item -Path $path -Recurse | |
} | |
Invoke-WebRequest -UseBasicParsing https://github.com/KZeronimo/PostBuildContent/archive/refs/heads/master.zip -OutFile C:\PostBuildContent.zip | |
Expand-Archive -Path C:\PostBuildContent.zip -DestinationPath $path | |
Move-Item (Join-Path $path 'PostBuildContent-master\*') $path | |
if (Test-Path $answersPath) { | |
Copy-Item $answersPath -Destination (Join-Path $path 'User_Answers.json') | |
} | |
Remove-Item -Path (Join-Path $path 'PostBuildContent-master') | |
Remove-Item -Path C:\PostBuildContent.zip | |
# Configure Windows Explorer Options | |
Set-WindowsExplorerOptions -EnableShowFileExtensions -EnableShowHiddenFilesFoldersDrives -EnableShowFullPathInTitleBar | |
# Trust PSGallery | |
Get-PackageProvider -Name NuGet -ForceBootstrap | |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
# Install Source Code Pro and Nerd Fonts | |
Write-BoxstarterMessage "Installing Source Code Pro and Source Code Pro Nerd Fonts" | |
cinst sourcecodepro --cacheLocation $chocoCache | |
cinst nerd-fonts-sourcecodepro --cacheLocation $chocoCache | |
# Install Cascadia Code Nerd Font | |
Write-BoxstarterMessage "Installing Cascadia Code Nerd & PL Font" | |
cinst nerd-fonts-cascadiacode --cacheLocation $chocoCache | |
$latestBrowserDownloadUrl = Invoke-WebRequest -UseBasicParsing -Uri "https://api.github.com/repos/microsoft/cascadia-code/releases/latest" | ConvertFrom-Json | Select-Object -ExpandProperty assets | Select-Object -ExpandProperty browser_download_url | Where-Object { $_ -match '.*\/[^\/]*OTF[^\/]*\.zip$|.*\/[^\/]*\.zip$' } | Select-Object -First 1 | |
& C:\_PostBuildContent\helpers\install-font.ps1 -Url $latestBrowserDownloadUrl -FontFilesFilter '*.otf' | |
# Install oh-my-posh | |
Write-BoxstarterMessage "Installing posh-git and oh-my-posh" | |
Install-Module -Name posh-git -Scope CurrentUser | |
winget install JanDeDobbeleer.OhMyPosh --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install PowerShell Core | |
Write-BoxstarterMessage "Installing PowerShell Core" | |
winget install Microsoft.PowerShell --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Git (core credential mgr intalled with git for windows) | |
Write-BoxstarterMessage "Installing Git" | |
winget install Git.Git --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Window Terminal | |
Write-BoxstarterMessage "Installing Windows Terminal" | |
winget install 9N0DX20HK701 --source msstore --silent --accept-source-agreements --accept-package-agreements | |
# Install Visual Studio Code | |
Write-BoxstarterMessage "Installing VS Code" | |
winget install Microsoft.VisualStudioCode --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Notepad++ | |
Write-BoxstarterMessage "Installing Notepad++" | |
winget install Notepad++.Notepad++ --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Google Chrome | |
Write-BoxstarterMessage "Installing Chrome" | |
winget install Google.Chrome --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Raspi Full Begin | |
# Install Azure IoT Hub Device Explorer Xplat | |
Write-BoxstarterMessage "Installing Azure IoT Hub Device Explorer Xplat" | |
winget install Microsoft.Azure.IoTExplorer --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install Etcher | |
Write-BoxstarterMessage "Installing Etcher" | |
winget install Balena.Etcher --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install PuTTY | |
Write-BoxstarterMessage "Installing PuTTY" | |
winget install XPFNZKSKLBP7RJ --source msstore --silent --accept-source-agreements --accept-package-agreements | |
# Install Rufus | |
Write-BoxstarterMessage "Installing Rufus" | |
winget install 9PC3H3V7Q9CH --source msstore --silent --accept-source-agreements --accept-package-agreements | |
# Install Teraterm | |
Write-BoxstarterMessage "Installing Teraterm" | |
winget install TeraTermProject.teraterm --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install WinSCP | |
Write-BoxstarterMessage "Installing WinSCP" | |
winget install WinSCP.WinSCP --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install 7zip | |
Write-BoxstarterMessage "Installing 7zip" | |
winget install 7zip.7zip --source winget --silent --accept-source-agreements --accept-package-agreements | |
# Install NetBean IDE CPP | |
# Write-BoxstarterMessage "Installing NetBeans IDE CPP" | |
# $packageName = 'NetBeans IDE CPP' | |
# $fileType = 'exe' | |
# $version = '8.2' | |
# $silentArgs = '--silent' | |
# $url = "http://download.netbeans.org/netbeans/$version/final/bundles/netbeans-$version-cpp-windows-x64.exe" | |
# $checksum = '4a6e333511a4c6db313aed8a8f2e7203986b83913dfd7f891410a116b254cd6c' | |
# $checksumType = 'sha256' | |
# Install-ChocolateyPackage -packageName $packageName -fileType $fileType -url64bit $url -checksum64 $checksum -checksumType64 $checksumType -silentArgs $silentArgs | |
# Refresh Environment | |
Write-BoxstarterMessage "Refresh Environment" | |
refreshenv | |
# Raspi End Begin | |
# Create root folder structure | |
Write-BoxstarterMessage "Creating root folder structure" | |
New-Item -Path "C:\_Src" -Type Directory -Force | |
New-Item -Path "C:\_Src\Prod" -Type Directory -Force | |
New-Item -Path "C:\_Src\Prod\Mesh" -Type Directory -Force | |
New-Item -Path "C:\_Src\Sdbx" -Type Directory -Force | |
# Remove Desktop Shortcuts | |
Write-BoxstarterMessage "Removing desktop shortcuts" | |
Get-ChildItem -Path "C:\Users\*\Desktop\*" -Recurse -Include *.lnk | Remove-Item -Force | |
# Deploy post build content | |
Write-BoxstarterMessage "Deploying post build content" | |
if (! (Test-Path -Path (Join-Path $env:UserProfile ".gitconfig"))) { | |
Copy-Item "C:\_PostBuildContent\git\.gitconfig" -Destination $env:UserProfile -Force | |
} | |
Copy-Item "C:\_PostBuildContent\terminal\Microsoft.PowerShell_profile.ps1" -Destination (New-Item (Join-Path $env:UserProfile "Documents\WindowsPowerShell") -Type container -Force) -Force | |
Copy-Item "C:\_PostBuildContent\terminal\Microsoft.PowerShell_profile.ps1" -Destination (New-Item (Join-Path $env:UserProfile "Documents\PowerShell") -Type container -Force) -Force | |
Copy-Item "C:\_PostBuildContent\terminal\wt_profiles_settings.json" -Destination (Join-Path $env:LocalAppData "Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json") -Force | |
Copy-Item "C:\_PostBuildContent\terminal\agnoster-mesh.omp.json" -Destination (Join-Path $env:LocalAppData "Programs\oh-my-posh\themes\agnoster-mesh.omp.json") -Force | |
Copy-Item -Path "C:\_PostBuildContent\themes\*" -Destination (New-Item (Join-Path $env:UserProfile "Pictures\Themes") -Type container -Force) -Recurse -Force | |
Copy-Item -Path "C:\_PostBuildContent\layouts\*" -Destination $env:LocalAppData -Recurse -Force | |
# Configure my .gitconfig | |
Write-BoxstarterMessage "Customizing gitconfig" | |
& C:\_PostBuildContent\git\configure-my-gitconfig.ps1 | |
# Setup configuration and dotfile tracking | |
$path = Join-Path $env:UserProfile ".myconf" | |
New-Item -Path ($path) -Type Directory -Force | |
Set-Location -Path $path | |
if (! (Test-Path -Path "HEAD")) { | |
Write-BoxstarterMessage "Setting up configuration and dotfile tracking" | |
git init --bare $path | |
Write-Output '*' >> $env:UserProfile/.myconf/info/exclude | |
} | |
# Clone OneFlow Repo | |
Set-Location -Path C:\_Src\Prod\Mesh | |
$path = "https://meshsystems@dev.azure.com/meshsystems/Mesh%20Systems/_git/Mesh.DevAutomation.OneFlow" | |
if (! (Test-Path -Path ($path -split '/')[-1])) { | |
Write-BoxstarterMessage "Cloning OneFlow repo" | |
git clone $path | |
} | |
# Clone DotNet Templates Repo | |
Set-Location -Path C:\_Src\Prod\Mesh | |
$path = "https://meshsystems@dev.azure.com/meshsystems/Mesh%20Systems/_git/Mesh.DotNet.Templates" | |
if (! (Test-Path -Path ($path -split '/')[-1])) { | |
Write-BoxstarterMessage "Cloning DotNet Templates repo" | |
git clone $path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment