Let's get started
For those how follow this blog I talked many times about Chocolatey. For all the others, Chocolatey is a Machine Package Manager, somewhat like apt-get (on Linux), but built with Windows in mind.
Assuming that you don't have Chocolatey installed, let's start by that. Open a command prompt (cmd.exe) as Administrator, and execute this command:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Now anytime you need an application you can simply do a choco install
command. This will download the latest version of the package online the last package, and install it on your PC.Here are some examples with popular applications:
Application | Command |
---|---|
Notepad++ | choco install notepadplusplus |
Atom | choco install atom |
7-Zip | choco install 7zip |
Skype | choco install skype |
You can find the complete list of all applications on the Chocolatey web site. Many other commands are also available to search, list and update some packages:
Command | Description |
---|---|
choco install atom -Version 0.140.0 |
Install old version (0.140.0) of Atom |
choco list nunit |
Show all package that contain nUnit |
choco update |
updates chocolatey to the latest version |
choco update notepadplusplus |
updates NotePad++ to the latest version |
Let's go a step further
Will it be nice if we could chain them? This is possible with Boxstarter, a repeatable, reboot resilient windows environment installations using Chocolatey packages. To install Fiddler, Atom, and Visual Studio 2013, simply type this command in Internet Explorer (IE) and Boxstarter will starts his magic.
http://boxstarter.org/package/fiddler4,atom,visualstudiocommunity2013
Note: This will work only in Internet Explorer (IE), on Chrome or Firefox you will need a "Click-Once" extension.
Turn it up to 11
Now that we know we can chain them, what is stooping us to create a script that will install ALL our favorite applications? Well, nothing!
Boxstarter is a very easy and powerful way to automate the installation of software. Here an example to show some of the great features supported by Boxstarter. In the following script I will: configure Windows, install the latest Windows updates, install Visual Studio Community 2013 with an extension and install many other applications.
# Windows Configuration
Update-ExecutionPolicy Unrestricted
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
Disable-InternetExplorerESC
Disable-UAC #Win8
Set-TaskbarSmall
if (Test-PendingReboot) { Invoke-Reboot }
# Update Windows and reboot if necessary
Install-WindowsUpdate -AcceptEula
if (Test-PendingReboot) { Invoke-Reboot }
# Install Visual Studio Community 2013
choco install choco install visualstudiocommunity2013
# VS extensions
Install-ChocolateyVsixPackage PowerShellTools http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597/file/112013/6/PowerShellTools.vsix
# Install WebPI (Platform Installer)
choco install webpi
# Install
# . SSDT
# . Microsoft Azure SDK - 2.4.1
# . Microsoft Azure SDK for .NET (VS 2012) - 2.4
C:\Program Files\Microsoft\Web Platform Installer>WebpiCmd.exe /Applications: SSDT, WindowsAzureSDK_2_4_1, VWDOrVs2012AzurePack.2.4
if (Test-PendingReboot) { Invoke-Reboot }
# Install Favourite Tools
choco install sourcetree
choco install resharper
choco install Atom
choco install LinqPad
choco install fiddler4
You can now execute this script executing the command in IE:
http://boxstarter.org/package/url?C:/dev/Demoscript.txt
In this case, the file was on a local folder, put it could have been in a share folder on another server, or somewhere online like in gist.github.com.Wrapping up
I hope it will help you to automate repetitive task and save time. For more information about Chocolatey or Boxstarter, go visit their respective web site. Any comments, suggestions and/or questions are welcome.
~Frank B