Skip to content

Instantly share code, notes, and snippets.

@devSarry
Forked from thitemple/dev_setup.ps1
Last active January 23, 2018 20:55
Show Gist options
  • Save devSarry/ead189ed427f4202ffef4adf0748f975 to your computer and use it in GitHub Desktop.
Save devSarry/ead189ed427f4202ffef4adf0748f975 to your computer and use it in GitHub Desktop.
A PowerShell script for installing a dev machine using Chocolatey.
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
# Packages
cinst -y hyper
cinst -y Gow
## Node, npm
cinst -y nodejs.install
## Git
cinst -y git.install
cinst -y poshgit
cinst -y git-credential-winstore
cinst -y github
cinst -y gitkraken
## Node, npm
cinst -y nodejs.install
npm install -g npm-windows-upgrade
## Editors
cinst -y visualstudiocode
cinst -y phpstorm
cinst -y webstorm
cinst -y sublimetext3
cinst SublimeText3.PowershellAlias -y
## Virtual Environment
cinst -y vagrant
cinst -y virtualbox
## Laravel
cinst -y php
cinst -y composer
## Ruby, Go, Python
cinst -y golang
cinst -y python
cinst -y pip
cinst -y easy.install
if (Test-PendingReboot) { Invoke-Reboot }
## Basics
cinst -y vlc
cinst -y GoogleChrome
cinst -y 7zip.install
cinst -y DotNet3.5
if (Test-PendingReboot) { Invoke-Reboot }
# Pinning Things
Install-ChocolateyPinnedTaskBarItem "$env:programfiles\Google\Chrome\Application\chrome.exe"
######################################################
# 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")
[Environment]::SetEnvironmentVariable("PHANTOMJS_BIN", "C:\tools\PhanomJS\phantomjs.exe", "User")
Write-Host
######################################################
# Download custom .bashrc file
######################################################
Write-Host "Creating .bashrc file for use with Git Bash"
$filePath = $HOME + "\.bashrc"
New-Item $filePath -type file -value ((new-object net.webclient).DownloadString('http://bit.ly/winbashrc'))
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
$gitexcludes = $home + "\.gitexcludes"
Add-Content $gitexcludes ((new-object net.webclient).DownloadString('http://bit.ly/gitexcludes'))
Write-Host
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
######################################################
# Install npm packages
######################################################
Write-Host "Install NPM packages"
npm install -g yo gulp karma bower jshint nodemon
Write-Host
######################################################
# 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
######################################################
# Download custom PowerShell profile file
######################################################
Write-Host "Creating custom $profile for Powershell"
if (!(test-path $profile)) {
New-Item -path $profile -type file -force
}
Add-Content $profile ((new-object net.webclient).DownloadString('http://bit.ly/profileps'))
Write-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment