Skip to content

Instantly share code, notes, and snippets.

@mikesigs
Forked from johnkattenhorn/DevEnvironment.ps1
Created December 9, 2015 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesigs/f77ee2c94e65fbbab1bf to your computer and use it in GitHub Desktop.
Save mikesigs/f77ee2c94e65fbbab1bf to your computer and use it in GitHub Desktop.
Boxstarter Script for VM-based Development Environment
function SetPowerPlan([string]$PreferredPlan)
{
Write-Host "Setting Powerplan to $PreferredPlan"
$guid = (Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "ElementName='$PreferredPlan'").InstanceID.tostring()
$regex = [regex]"{(.*?)}$"
$newpowerVal = $regex.Match($guid).groups[1].value
# setting power setting to high performance
powercfg -S $newpowerVal
}
try {
# Boxstarter options
$Boxstarter.RebootOk=$false # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
# Enable-RemoteDesktop
Disable-InternetExplorerESC
#Disable-UAC
Set-TaskbarOptions -Lock
# Power plan setup
SetPowerPlan "High performance"
Write-BoxstarterMessage "Setting Standby Timeout to Never"
& powercfg.exe -change -standby-timeout-ac 0
& powercfg.exe -change -standby-timeout-dc 0
Write-BoxstarterMessage "Setting Monitor Timeout to Never"
& powercfg.exe -change -monitor-timeout-ac 0
& powercfg.exe -change -monitor-timeout-dc 0
Write-BoxstarterMessage "Setting Disk Timeout to Never"
& powercfg.exe -change -disk-timeout-ac 0
& powercfg.exe -change -disk-timeout-dc 0
Write-BoxstarterMessage "Turning off Windows Hibernation"
& powercfg.exe -h off
# DotNet Runtime
cinst dotnet3.5
cinst dotnet4.5.1
# Install SQL Server 2014 Express and Tools (Neither seem to work with Boxstarter Remote)
#cinst -debug mssql2014express-defaultinstance
#cinst -debug MsSqlServerManagementStudio2014Express
# Install SQL Server 2014 Developer Edition from local repo
try {
if(Test-Path "HKLM:\Software\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"){
if((Get-ItemProperty -Path HKLM:\Software\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion).CurrentVersion -ge "11.0.3000.0") {
Write-Host "MS SQL already installed"
}
}
else {
$adminsGroupName = (New-Object Security.Principal.SecurityIdentifier 'S-1-5-32-544').Translate([Security.Principal.NTAccount]).Value
$currentUser = Get-CurrentUser
$setupExe = "\\glywlq1\Software\SQL2014_ENU_x64\setup.exe"
$setupArgs = "/q /INDICATEPROGRESS /ACTION=Install /ROLE=ALLFeatures_WithDefaults /TCPENABLED=1 /INSTANCENAME=MSSQLSERVER /SKIPRULES=`"RebootRequiredCheck`" /SQLSVCACCOUNT=`"NT AUTHORITY\Network Service`" /ASSYSADMINACCOUNTS=`"$($currentUser.Domain)\$($currentUser.Name)`" /SQLSYSADMINACCOUNTS=`"$adminsGroupName`" `"$($currentUser.Domain)\$($currentUser.Name)`" /AGTSVCACCOUNT=`"NT AUTHORITY\Network Service`" /IACCEPTSQLSERVERLICENSETERMS "
Invoke-FromTask "$setupExe $setupArgs" -idletimeout 0
#Install-ChocolateyInstallPackage 'Sql2014' 'exe' "/q /INDICATEPROGRESS /ACTION=Install /ROLE=ALLFeatures_WithDefaults /TCPENABLED=1 /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=`"NT AUTHORITY\Network Service`" /ASSYSADMINACCOUNTS=`"$($currentUser.Domain)\$($currentUser.Name)`" /SQLSYSADMINACCOUNTS=`"$adminsGroupName`" `"$($currentUser.Domain)\$($currentUser.Name)`" /AGTSVCACCOUNT=`"NT AUTHORITY\Network Service`" /IACCEPTSQLSERVERLICENSETERMS " @(0,3010)
netsh advfirewall firewall add rule name="Allow Access to SQL" Dir=In Action=allow Protocol=tcp LocalPort=1433 Profile=Domain
Write-ChocolateySuccess 'Sql2014'
}
}
catch {
Write-ChocolateyFailure 'Sql2014' $($_.Exception.Message)
throw
}
# Install Visual Studio 2013 Ultimate
cinst VisualStudio2013Ultimate -InstallArguments "/Features:'Blend WebTools'"
# Install Visual Studio 2014 Update 4
cinst VS2013.4
# Visual Studio SDK
cinst VS2013SDK
# Xamarin
cinst xamarin-studio
cinst xamarin-visualstudio
# Install Visual Studio 2015 Ultimate
#cinst VisualStudio2015Ultimate -Pre -InstallArguments "/Features:'Blend WebTools'"
# Web PI Packages
cinst WindowsAzureSDK_2_5.VS2013 -source webpi # Azure SDK
cinst OfficeToolsForVS2013Update1 -source webpi # Office 2013 Developer Tools
# VS extensions
Install-ChocolateyVsixPackage ProductivityPowerTools2013 https://visualstudiogallery.msdn.microsoft.com/dbcb8670-889e-4a54-a226-a48a15e4cace/file/117115/4/ProPowerTools.vsix
Install-ChocolateyVsixPackage NuGetPackageManager https://visualstudiogallery.msdn.microsoft.com/4ec1526c-4a8c-4a84-b702-b21a8f5293ca/file/105933/7/NuGet.Tools.2013.vsix
Install-ChocolateyVsixPackage TeamFoundationServerPowerTools2013 https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f/file/112253/3/Visual%20Studio%20Team%20Foundation%20Server%202013%20Update%202%20Power%20Tools%20.msi
Install-ChocolateyVsixPackage IndentGuides https://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30/file/48932/20/IndentGuide%20v14.vsix
Install-ChocolateyVsixPackage VSCommands https://visualstudiogallery.msdn.microsoft.com/c6d1c265-7007-405c-a68b-5606af238ece/file/106247/18/SquaredInfinity.VSCommands.VS12.vsix
Install-ChocolateyVsixPackage SQLiteRT https://visualstudiogallery.msdn.microsoft.com/1d04f82f-2fe9-4727-a2f9-a2db127ddc9a/file/111148/14/sqlite-winrt81-3080702.vsix
Install-ChocolateyVsixPackage SQLiteWinPhone81 https://visualstudiogallery.msdn.microsoft.com/5d97faf6-39e3-4048-a0bc-adde2af75d1b/file/132406/7/sqlite-wp81-winrt-3080702.vsix
Install-ChocolateyVsixPackage SQLiteToolbox https://visualstudiogallery.msdn.microsoft.com/0e313dfd-be80-4afb-b5e9-6e74d369f7a1/file/29445/72/SqlCeToolbox.vsix
Install-ChocolateyVsixPackage VSColorOutput https://visualstudiogallery.msdn.microsoft.com/f4d9c2b5-d6d7-4543-a7a5-2d7ebabc2496/file/63103/9/VSColorOutput.vsix
Install-ChocolateyVsixPackage PowerShellTools http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597/file/112013/6/PowerShellTools.vsix
Install-ChocolateyVsixPackage WebEssentials2013 https://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361/file/105627/42/WebEssentials2013.vsix
Install-ChocolateyVsixPackage T4Toolbox http://visualstudiogallery.msdn.microsoft.com/791817a4-eb9a-4000-9c85-972cc60fd5aa/file/116854/1/T4Toolbox.12.vsix
Install-ChocolateyVsixPackage StopOnFirstBuildError http://visualstudiogallery.msdn.microsoft.com/91aaa139-5d3c-43a7-b39f-369196a84fa5/file/44205/3/StopOnFirstBuildError.vsix
# Node
cinst nodejs
cinst nodejs.install
cinst npm
# Other dev tools
cinst console2
cinst console-devel
cinst fiddler4
#cinst ProcExp
cinst NugetPackageExplorer
cinst sysinternals
#cinst windbg
cinst wingrep
cinst linqpad
cinst papercut
cinst resharper-platform
# Browsers
cinst googlechrome
cinst firefox
cinst Opera
cinst safari
# Office
#cinst Office365ProPlus
# Other essential tools
#cinst 7zip
cinst 7zip.install
cinst adobereader
cinst javaruntime
cinst treesizefree
# git
#cinst git
cinst git.install
cinst poshgit
cinst git-credential-winstore
# Text Editor
#cinst markdownpad2
cinst SublimeText3
cinst SublimeText3.PackageControl
#cinst Microsoft-Hyper-V-All -source windowsFeatures
#cinst IIS-WebServerRole -source windowsfeatures
#cinst IIS-HttpCompressionDynamic -source windowsfeatures
#cinst IIS-ManagementScriptingTools -source windowsfeatures
#cinst IIS-WindowsAuthentication -source windowsfeatures
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Google\Chrome\Application\chrome.exe"
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Mozilla Firefox\firefox.exe"
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe"
#Install-ChocolateyPinnedTaskBarItem "$($Boxstarter.programFiles86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe"
#Install-ChocolateyPinnedTaskBarItem "$env:programfiles\Sublime Text 3\sublime_text.exe"
# Other Setup Items
# Setup
Install-ChocolateyFileAssociation ".txt" "$env:programfiles\Sublime Text 3\sublime_text.exe"
Install-ChocolateyFileAssociation ".log" "$env:programfiles\Sublime Text 3\sublime_text.exe"
Install-ChocolateyFileAssociation ".config" "$env:programfiles\Sublime Text 3\sublime_text.exe"
Install-ChocolateyFileAssociation ".xml" "$env:programfiles\Sublime Text 3\sublime_text.exe"
Install-ChocolateyFileAssociation ".ps1" "$env:programfiles\Sublime Text 3\sublime_text.exe"
Install-ChocolateyFileAssociation ".psm" "$env:programfiles\Sublime Text 3\sublime_text.exe"
# Moved here as it stalls the process
cinst TelerikControlPanel
# Update Windows and reboot if necessary
Install-WindowsUpdate -AcceptEula
# Check name of the machine and rename if required
# Get the virtual machine name from the parent partition
$vmName = (Get-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").VirtualMachineName
# Replace any non-alphanumeric characters with an underscore
$vmName = [Regex]::Replace($vmName,"\W","-")
# Trim names that are longer than 15 characters
$vmName = $vmName.Substring(0,[System.Math]::Min(15, $vmName.Length))
# Check the trimmed and cleaned VM name against the guest OS name
# If it is different, change the guest OS name and reboot
if($env:computername -ne $vmName) {
Write-BoxstarterMessage "Renaming Computer from ${env:computername} To ${vmName}";
Rename-Computer -NewName $vmName -LocalCredential administrator
}
# Update Windows
Install-WindowsUpdate -AcceptEula
Write-ChocolateySuccess 'DevelopmentEnvironment'
} catch {
Write-ChocolateyFailure 'DevelopmentEnvironment' $($_.Exception.Message)
throw
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment