-
-
Save Jeff-Walker/32b933deeead4aa4b95de7e4a479ef1a to your computer and use it in GitHub Desktop.
A PowerShell script for installing a dev machine using Chocolatey.
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
function Add-Path() { | |
[Cmdletbinding()] | |
param([parameter(Mandatory=$True,ValueFromPipeline=$True,Position=0)][String[]]$AddedFolder) | |
# Get the current search path from the environment keys in the registry. | |
$OldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path | |
# See if a new folder has been supplied. | |
if (!$AddedFolder) { | |
Return 'No Folder Supplied. $ENV:PATH Unchanged' | |
} | |
# See if the new folder exists on the file system. | |
if (!(TEST-PATH $AddedFolder)) | |
{ Return 'Folder Does not Exist, Cannot be added to $ENV:PATH' }cd | |
# See if the new Folder is already in the path. | |
if ($ENV:PATH | Select-String -SimpleMatch $AddedFolder) | |
{ Return 'Folder already within $ENV:PATH' } | |
# Set the New Path | |
$NewPath=$OldPath+';'+$AddedFolder | |
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath | |
# Show our results back to the world | |
Return $NewPath | |
} | |
###################################################### | |
# Install apps using Chocolatey | |
###################################################### | |
Write-Host "Installing Chocolatey" | |
iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall')) | |
Write-Host | |
Write-Host "Installing applications from Chocolatey" | |
cinst git -y | |
cinst gitkraken -y | |
cinst poshgit -y | |
cinst sublimetext3 -y | |
cinst sublimetext3.packagecontrol | |
cinst cmder -y | |
cinst putty -y | |
cinst GoogleChrome -y | |
cinst beyondcompare -y | |
cinst 7zip -y | |
cinst filezilla -y | |
cinst dropbox -y | |
cinst NugetPackageExplorer -y | |
choco install lastpass -y | |
cinst lastpass-for-applications -y | |
cinst chocolateygui -y | |
cinst linqpad4 -y | |
Write-Host | |
###################################################### | |
# Set environment variables | |
###################################################### | |
Write-Host "Setting home variable" | |
[Environment]::SetEnvironmentVariable("HOME", $HOME, "User") | |
[Environment]::SetEnvironmentVariable("CHROME_BIN", "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "User") | |
Write-Host | |
###################################################### | |
# Install Windows installer through WebPI | |
###################################################### | |
Write-Host "Installing apps from WebPI" | |
cinst WindowsInstaller31 -source webpi | |
cinst WindowsInstaller45 -source webpi | |
Write-Host | |
Write-Host | |
###################################################### | |
# Add Git to the path | |
###################################################### | |
Write-Host "Adding Git\bin to the path" | |
Add-Path "C:\Program Files (x86)\Git\bin" | |
Write-Host | |
###################################################### | |
# Configure Git globals | |
###################################################### | |
Write-Host "Configuring Git globals" | |
$userName = Read-Host 'Enter your name for git configuration' | |
$userEmail = Read-Host 'Enter your email for git configuration' | |
& 'C:\Program Files (x86)\Git\bin\git' config --global user.email $userEmail | |
& 'C:\Program Files (x86)\Git\bin\git' config --global user.name $userName | |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") | |
###################################################### | |
# Generate public/private rsa key pair | |
###################################################### | |
Write-Host "Generating public/private rsa key pair" | |
Set-Location $home | |
$dirssh = "$home\.ssh" | |
mkdir $dirssh | |
$filersa = $dirssh + "\id_rsa" | |
ssh-keygen -t rsa -f $filersa -q -C $userEmail | |
Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment