Skip to content

Instantly share code, notes, and snippets.

@bdangit
Last active March 31, 2019 13:30
Show Gist options
  • Save bdangit/54dfeac3a47fc3ce6a15ca174e487225 to your computer and use it in GitHub Desktop.
Save bdangit/54dfeac3a47fc3ce6a15ca174e487225 to your computer and use it in GitHub Desktop.
Basic Windows Workstation Configuration
# install awesome packages
chocolatey_package "git" do
options '-params "/GitAndUnixToolsOnPath /NoAutoCrlf"'
end
packages = %w[
conemu
habitat
winmerge
vagrant
packer
terraform
jq
ILMerge
microsoft-build-tools
vcredist2010
vcredist2013
pester
atom
vim
wireshark
screentogif
]
packages.each do |package_name|
chocolatey_package package_name
end
chocolatey_package 'visualstudio2017community' do
options '--params "--passive"'
end
# install gems to enhance development experience
gems = %w[
kitchen-hyperv
kitchen-pester
kitchen-dsc
pry
pry-byebug
pry-stack_explorer
appbundle-updater
]
gems.each do |gem|
chef_gem gem do
compile_time false if respond_to?(:compile_time)
end
end
# enhance visual studio with extensions
extensions = %w[
ms-vcode.PowerShell
Pendrica.Chef
dracula-theme.theme-dracula
]
extensions.each do |ext|
execute "install vscode extension #{ext}" do
command "code --install-extension #{ext}"
end
end
# enhance powershell
powershell_package 'PSReadline'
powershell_package 'posh-git'
# make secure - disable SMBv1
powershell_script 'disable SMBv1' do
code 'Disable-WindowsOptionalFeature -NoRestart -Online -FeatureName SMB1Protocol'
end
# Setup my execution policy for both the 64 bit and 32 bit shells
Set-Executionpolicy remotesigned
Start-Job -runas32 {set-executionpolicy remotesigned} | Receive-Job -wait
# Install fixed version of ChefDK
Invoke-Restmethod 'https://omnitruck.chef.io/install.ps1' | IEX
Install-Project chefdk -verbose
# Install Chocolatey
IEX ((New-Object Net.Webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n allowGlobalConfirmation
# Get a basic setup recipe
$BasicSource = 'https://gist.githubusercontent.com/bdangit/54dfeac3a47fc3ce6a15ca174e487225/raw/c97349459070f71eaaac1a3967c9d4ee4e4a1532/basic.rb'
Invoke-RestMethod -UseBasicParsing $BasicSource | out-file -encoding ascii -filepath c:/basic.rb
# We dont need any Windows 10 Apps
Get-AppxPackage | Remove-AppxPackage 2>&1>$null
# We do want calculator :)
Get-AppxPackage -allusers *windowscalculator* | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}
# Use Chef Apply to setup
chef-apply c:/basic.rb
Write-Host "executed chef recipe c:/basic.rb"
Import-Module posh-git
Import-Module PSReadline
$env:EDITOR = "vim"
# aliases
Set-Alias open explorer.exe -option AllScope
Set-Alias make mingw32-make.exe -option AllScope
Set-Alias p packer.exe -option AllScope
Set-Alias v vagrant.exe -option AllScope
Set-Alias t terraform.exe -Option AllScope
Set-Alias d docker.exe -Option Allscope
Set-Alias dm docker-machine.exe -option AllScope
# docker-machine stuff
function dmdev {
& dm env dev | Invoke-Expression
}
# vagrant stuff
$env:VAGRANT_DEFAULT_PROVIDER="vmware_workstation"
$env:VAGRANT_HOME="$HOME\.vagrant.d"
# Add gobin to PATH
$env:GOPATH = "$HOME\go"
$env:GOROOT = "C:\tools\go"
function Invoke-PesterJob
{
[CmdletBinding(DefaultParameterSetName='LegacyOutputXml')]
param(
[Parameter(Position=0)]
[Alias('Path','relative_path')]
[System.Object[]]
${Script},
[Parameter(Position=1)]
[Alias('Name')]
[string[]]
${TestName},
[Parameter(Position=2)]
[switch]
${EnableExit},
[Parameter(ParameterSetName='LegacyOutputXml', Position=3)]
[string]
${OutputXml},
[Parameter(Position=4)]
[Alias('Tags')]
[string[]]
${Tag},
[string[]]
${ExcludeTag},
[switch]
${PassThru},
[System.Object[]]
${CodeCoverage},
[switch]
${Strict},
[Parameter(ParameterSetName='NewOutputSet', Mandatory=$true)]
[string]
${OutputFile},
[Parameter(ParameterSetName='NewOutputSet', Mandatory=$true)]
[ValidateSet('LegacyNUnitXml','NUnitXml')]
[string]
${OutputFormat},
[switch]
${Quiet}
)
$params = $PSBoundParameters
Start-Job -ScriptBlock { Set-Location $using:pwd; Invoke-Pester @using:params } |
Receive-Job -Wait -AutoRemoveJob
}
Set-Alias ipj Invoke-PesterJob
# Setup PATH
# Add mybin to PATH
# $env:Path += ";$HOME\bin"
# $env:Path += ";C:\tools\mingw64\bin"
# $env:Path += ";C:\habitat"
# $env:Path += ";C:\Program Files (x86)\VMware\VMware Workstation"
# $env:Path += ";C:\Program Files (x86)\VMware\VMware Workstation\OVFTool"
# $env:Path += ";$env:GOROOT\bin;$env:GOPATH\bin"
# PROMPT
function Prompt {
$realLASTEXITCODE = $LASTEXITCODE
Write-Host "$ENV:USERNAME@" -NoNewline -ForegroundColor DarkYellow
Write-Host "$ENV:COMPUTERNAME" -NoNewline -ForegroundColor DarkMagenta
Write-Host " [" -NoNewline -ForegroundColor DarkGray
Write-Host (Get-Date -UFormat "%Y%m%d-%H%M") -NoNewline -ForegroundColor Magenta
Write-Host "][" -NoNewline -ForegroundColor DarkGray
Write-Host $($(Get-Location) -replace ($env:USERPROFILE).Replace('\','\\'), "~") -NoNewline -ForegroundColor Blue
Write-Host "]" -NoNewline -ForegroundColor DarkGray
Write-VcsStatus
$global:LASTEXITCODE = $realLASTEXITCODE
#
#Write-Host ""
If ($PSDebugContext.InvocationInfo) {
Write-Host " [DBG]"
}
return " > "
}

This will help bootstrap your windows workstation to be a better badass development system.

Copy and past the bootstrap.ps1 lines into Powershell and let it rip.

@bdangit
Copy link
Author

bdangit commented Jul 25, 2017

This is based on Steve Murawskis work. See his blog post on simplified-chef-workstation

@craigontour
Copy link

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