Skip to content

Instantly share code, notes, and snippets.

@MattHuntington
Last active September 24, 2015 02:47
Show Gist options
  • Save MattHuntington/b77c361ed8048d37f7ce to your computer and use it in GitHub Desktop.
Save MattHuntington/b77c361ed8048d37f7ce to your computer and use it in GitHub Desktop.
Setup Dev Machine
function Install-ChocolateyPinnedTaskBarItem {
<#
.SYNOPSIS
Creates an item in the task bar linking to the provided path.
.PARAMETER TargetFilePath
The path to the application that should be launched when clicking on the task bar icon.
.EXAMPLE
Install-ChocolateyPinnedTaskBarItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
This will create a Visual Studio task bar icon.
#>
param(
[string] $targetFilePath
)
Write-Debug "Running 'Install-ChocolateyPinnedTaskBarItem' with targetFilePath:`'$targetFilePath`'";
if (test-path($targetFilePath)) {
$verb = "Pin To Taskbar"
$path= split-path $targetFilePath
$shell=new-object -com "Shell.Application"
$folder=$shell.Namespace($path)
$item = $folder.Parsename((split-path $targetFilePath -leaf))
$itemVerb = $item.Verbs() | ? {$_.Name.Replace("&","") -eq $verb}
if($itemVerb -eq $null){
Write-Host "TaskBar verb not found for $item. It may have already been pinned"
} else {
$itemVerb.DoIt()
}
Write-Host "`'$targetFilePath`' has been pinned to the task bar on your desktop"
} else {
$errorMessage = "`'$targetFilePath`' does not exist, not able to pin to task bar"
}
if($errorMessage){
Write-Error $errorMessage
throw $errorMessage
}
}
function Install-ChocolateyVsixPackage {
<#
.SYNOPSIS
Downloads and installs a VSIX package for Visual Studio
.PARAMETER PackageName
The name of the package we want to download - this is
arbitrary, call it whatever you want. It's recommended
you call it the same as your nuget package id.
.PARAMETER VsixUrl
The URL of the package to be installed
.PARAMETER VsVersion
The Major version number of Visual Studio where the
package should be installed. This is optional. If not
specified, the most recent Visual Studio installation
will be targetted.
.PARAMETER Checksum
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
.EXAMPLE
Install-ChocolateyVsixPackage "MyPackage" http://visualstudiogallery.msdn.microsoft.com/ea3a37c9-1c76-4628-803e-b10a109e7943/file/73131/1/AutoWrockTestable.vsix
This downloads the AutoWrockTestable VSIX from the Visual Studio Gallery and installs it to the latest version of VS.
.EXAMPLE
Install-ChocolateyVsixPackage "MyPackage" http://visualstudiogallery.msdn.microsoft.com/ea3a37c9-1c76-4628-803e-b10a109e7943/file/73131/1/AutoWrockTestable.vsix 11
This downloads the AutoWrockTestable VSIX from the Visual Studio Gallery and installs it to Visual Studio 2012 (v11.0).
.NOTES
VSIX packages are Extensions for the Visual Studio IDE.
The Visual Sudio Gallery at
http://visualstudiogallery.msdn.microsoft.com/ is the
public extension feed and hosts thousands of extensions.
You can locate a VSIX Url by finding the download link
of Visual Studio extensions on the Visual Studio Gallery.
#>
param(
[string]$packageName,
[string]$vsixUrl,
[int]$vsVersion=0,
[string] $checksum = '',
[string] $checksumType = ''
)
Write-Debug "Running 'Install-ChocolateyVsixPackage' for $packageName with vsixUrl:`'$vsixUrl`', vsVersion: `'$vsVersion`', checksum: `'$checksum`', checksumType: `'$checksumType`' ";
if($vsVersion -eq 0) {
if ([System.IntPtr]::Size -eq 4)
{
<# 32bits system case #>
$versions=(get-ChildItem HKLM:SOFTWARE\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName -match "^[0-9\.]+$") } | ? {$_.property -contains "InstallDir"} | sort {[int]($_.PSChildName)} -descending)
}
else
{
$versions=(get-ChildItem HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName -match "^[0-9\.]+$") } | ? {$_.property -contains "InstallDir"} | sort {[int]($_.PSChildName)} -descending)
}
if($versions -and $versions.Length){
$version = $versions[0]
}elseif($versions){
$version = $versions
}
}
else {
if ([System.IntPtr]::Size -eq 4)
{
<# 32bits system case #>
$versions=(get-ChildItem HKLM:SOFTWARE\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName.EndsWith("$vsVersion.0")) } | ? {$_.property -contains "InstallDir"})
}
else
{
$version=(get-ChildItem HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName.EndsWith("$vsVersion.0")) } | ? {$_.property -contains "InstallDir"})
}
}
if($version){
$vnum=$version.PSPath.Substring($version.PSPath.LastIndexOf('\')+1)
if($vnum -as [int] -lt 10) {
Write-ChocolateyFailure $packageName "This installed VS version, $vnum, does not support installing VSIX packages. Version 10 is the minimum acceptable version."
return
}
$dir=(get-itemProperty $version.PSPath "InstallDir").InstallDir
$installer = Join-Path $dir "VsixInstaller.exe"
}
if($installer) {
$download="$env:temp\$($packageName.Replace(' ','')).vsix"
try{
Get-ChocolateyWebFile $packageName $download $vsixUrl -checksum $checksum -checksumType $checksumType
}
catch {
Write-ChocolateyFailure $packageName "There were errors attempting to retrieve the vsix from $vsixUrl. The error message was '$_'."
return
}
Write-Debug "Installing VSIX using $installer"
$exitCode = Install-Vsix "$installer" "$download"
if($exitCode -gt 0 -and $exitCode -ne 1001) { #1001: Already installed
Write-ChocolateyFailure $packageName "There was an error installing '$packageName'. The exit code returned was $exitCode."
return
}
Write-ChocolateySuccess $packageName
}
else {
Write-ChocolateyFailure $packageName "Visual Studio is not installed or the specified version is not present."
}
}
function Install-Vsix($installer, $installFile) {
Write-Host "Installing $installFile using $installer"
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName=$installer
$psi.Arguments="/q $installFile"
$s = [System.Diagnostics.Process]::Start($psi)
$s.WaitForExit()
return $s.ExitCode
}
# make it so we don't have to agree to prompts
chocolatey feature enable -n=allowGlobalConfirmation #test with error about future versions of chocolatey
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false
# Setup windows options
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart -EnableListDesktopAppsFirst
Enable-RemoteDesktop
Disable-InternetExplorerESC
if (Test-PendingReboot) { Invoke-Reboot }
# install devpack before windows updates so it won't install the non-dev version first
cinst netfx-4.5.2-devpack
if (Test-PendingReboot) { Invoke-Reboot }
# Install windows updates to make sure we're ready for installs.
Install-WindowsUpdate -getUpdatesFromMS -acceptEula
if (Test-PendingReboot) { Invoke-Reboot }
#setup chocolatey
cinst chocolatey
cinst chocolateygui
if (Test-PendingReboot) { Invoke-Reboot }
# media players/viewers
cinst picasa
cinst cutepdf
cinst adobereader
cinst nitroreader.install
cinst vlc
cinst paint.net
cinst mpc-hc
cinst handbrake.install # chocolatey is pointing at old version
if (Test-PendingReboot) { Invoke-Reboot }
# web stuff
cinst flashplayerplugin -y
cinst google-chrome-x64 -y
cinst pidgin
cinst logmein.client
cinst fiddler4
cinst firefox
cinst opera
cinst maxthon
cinst googledrive
cinst silverlight
if (Test-PendingReboot) { Invoke-Reboot }
# dev tools
cinst libreoffice
cinst beyondcompare
cinst filezilla
cinst filezilla.server
cinst notepadplusplus.install
cinst linqpad
cinst rdcman
cinst virtualbox
# virtualbox.extensionpack #currrent it is out of date but add back in when they update to 5.0
cinst github
cinst putty
cinst tortoisesvn
if (Test-PendingReboot) { Invoke-Reboot }
cinst webpi
cinst visualstudiocode
cinst procmon
cinst windbg
cinst webdeploy
if (Test-PendingReboot) { Invoke-Reboot }
# misc apps
cinst keepass.install
cinst malwarebytes
cinst windirstat
cinst winrar
cinst audacity
cinst tor-browser
cinst steam
cinst qbittorrent
cinst recuva
cinst openvpn -InstallArguments "/SELECTTAP=1"
if (Test-PendingReboot) { Invoke-Reboot }
# SQL server
cinst mssqlserver2012express
if (Test-PendingReboot) { Invoke-Reboot }
cinst mssqlservermanagementstudio2014express
if (Test-PendingReboot) { Invoke-Reboot }
# visual studio
cinst VisualStudio2015Community -packageParameters "--Features SQL"
if (Test-PendingReboot) { Invoke-Reboot }
# TODO: Update this to update 5
# cinst vs2013.4
if (Test-PendingReboot) { Invoke-Reboot }
# visual studio additions
#cinst vs2013.powertools
#cinst vs2013sdk
if (Test-PendingReboot) { Invoke-Reboot }
#cinst visualstudio2013-webessentials.vsix
#cinst resharper-platform
#cinst visualsvn
#cinst nugetpackagemanager # Error returned code 2003
# final check to make sure everything is updated
Install-WindowsUpdate -getUpdatesFromMS -acceptEula
if (Test-PendingReboot) { Invoke-Reboot }
# restore confirmation prompts
chocolatey feature disable -n=allowGlobalConfirmation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment