Skip to content

Instantly share code, notes, and snippets.

@digitalbanana
Last active September 8, 2016 22:12
Show Gist options
  • Save digitalbanana/e6a3a8b85c5d7418350b20f0d762dfd6 to your computer and use it in GitHub Desktop.
Save digitalbanana/e6a3a8b85c5d7418350b20f0d762dfd6 to your computer and use it in GitHub Desktop.
initialize vm with chocolatey and intellij
function Install-NeededFor {
param(
[string] $packageName = ''
,[bool] $defaultAnswer = $true
)
if ($packageName -eq '') {return $false}
$yes = '6'
$no = '7'
$msgBoxTimeout='-1'
$defaultAnswerDisplay = 'Yes'
$buttonType = 0x4;
if (!$defaultAnswer) { $defaultAnswerDisplay = 'No'; $buttonType= 0x104;}
$answer = $msgBoxTimeout
try {
$timeout = 10
$question = "Do you need to install $($packageName)? Defaults to `'$defaultAnswerDisplay`' after $timeout seconds"
$msgBox = New-Object -ComObject WScript.Shell
$answer = $msgBox.Popup($question, $timeout, "Install $packageName", $buttonType)
}
catch {
}
if ($answer -eq $yes -or ($answer -eq $msgBoxTimeout -and $defaultAnswer -eq $true)) {
write-host "Installing $packageName"
return $true
}
write-host "Not installing $packageName"
return $false
}
# Install Chocolatey
if (Install-NeededFor 'chocolatey') {
iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))
}
# Install Maven
if (Install-NeededFor 'maven') {
choco install maven -y
}
# Install jdk8
if (Install-NeededFor 'jdk8') {
choco install jdk8 -y
}
# Install jdk8
if (Install-NeededFor 'git') {
choco install git -y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment