Skip to content

Instantly share code, notes, and snippets.

@kelbyers
Last active May 15, 2020 21:51
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 kelbyers/f6ef335bbe8ed556e079a527046a02da to your computer and use it in GitHub Desktop.
Save kelbyers/f6ef335bbe8ed556e079a527046a02da to your computer and use it in GitHub Desktop.
Boxstarter MonoDevelop
# install boxstarter
. { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
# run boxstarter with VisualStudio 2017 community gist (below)
$cred = Get-Credential IEUser ; Install-BoxstarterPackage -cred $cred `
-PackageName `
https://gist.githubusercontent.com/kelbyers/f6ef335bbe8ed556e079a527046a02da/raw/aafcb55077edb85f29cd6f3aaf172b80bc89ec1a/vscomdevelop.ps1
# run boxstarter with VBoxGuest additions and windows updates (next lines)
$cred = Get-Credential IEUser ; Install-BoxstarterPackage -cred $cred `
-PackageName `
https://gist.githubusercontent.com/kelbyers/f6ef335bbe8ed556e079a527046a02da/raw/c6206d3a8826364e5abbf4fdde457e31fc223da7/winupdate.ps1
$Boxstarter.RebootOk = $true
$Boxstarter.NoPassword = $false
$Boxstarter.AutoLogin = $true
$checkpointPrefix = 'BoxStarter:Checkpoint:'
function Get-CheckpointName {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName
)
return "$checkpointPrefix$CheckpointName"
}
function Set-Checkpoint {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName,
[Parameter(Mandatory = $true)]
[string]
$CheckpointValue
)
$key = Get-CheckpointName $CheckpointName
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Machine") # for reboots
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Process") # for right now
}
function Use-Checkpoint {
param(
[string]
$CheckpointName,
[string]
$SkipMessage,
[scriptblock]
$Function
)
$checkpoint = Get-Checkpoint -CheckpointName $CheckpointName
if (-not $checkpoint) {
$Function.Invoke($Args)
Set-Checkpoint -CheckpointName $CheckpointName -CheckpointValue 1
}
else {
Write-BoxstarterMessage $SkipMessage
}
}
function Get-Checkpoint {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName
)
$key = Get-CheckpointName $CheckpointName
[Environment]::GetEnvironmentVariable($key, "Process")
}
function Clear-Checkpoints {
$checkpointMarkers = Get-ChildItem Env: | Where-Object { $_.name -like "$checkpointPrefix*" } | Select-Object -ExpandProperty name
foreach ($checkpointMarker in $checkpointMarkers) {
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Machine")
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Process")
}
}
function InitialReboot {
$CheckpointName = 'InitialReboot'
$Function = ${Function:Invoke-Reboot}
$SkipMessage = 'Already Rebooted'
$checkpoint = Get-Checkpoint -CheckpointName $CheckpointName
if (-not $checkpoint) {
Set-Checkpoint -CheckpointName $CheckpointName -CheckpointValue 1
$Function.Invoke($Args)
}
else {
Write-BoxstarterMessage $SkipMessage
}
}
function Install-OsUpdates {
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
if (Test-PendingReboot) { Invoke-Reboot }
}
function Install-MonoDevelop {
choco install monodevelop --limitoutput
Update-Path
}
function Install-PoshGit {
cinst poshgit
}
function Install-GitCredentialWinstore {
cinst git-credential-winstore
}
function Update-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Set-RegionalSettings {
&"$env:windir\system32\tzutil.exe" /s "Central Standard Time"
}
function Enable-ChocolateyFeatures {
choco feature enable --name=allowGlobalConfirmation
}
function Disable-ChocolateyFeatures {
choco feature disable --name=allowGlobalConfirmation
}
function Install-ClassicShell {
choco install classic-shell
}
Use-Checkpoint `
-Function ${Function:Set-RegionalSettings} `
-CheckpointName 'RegionalSettings' `
-SkipMessage 'Regional settings are already configured'
Set-WindowsExplorerOptions -EnableShowFileExtensions
Enable-RemoteDesktop
Use-Checkpoint `
-Function ${Function:Install-ClassicShell} `
-CheckpointName 'InstallClassicShell' `
-SkipMessage 'Classic Shell already installed'
Use-Checkpoint `
-Function ${Function:Enable-ChocolateyFeatures} `
-CheckpointName 'IntialiseChocolatey' `
-SkipMessage 'Chocolatey features already configured'
# cinst git-credential-winstore
Use-Checkpoint `
-Function ${Function:Install-GitCredentialWinstore} `
-CheckpointName 'InstallGitCredentialWinstore' `
-SkipMessage 'GitCredentialWinstore already installed'
Use-Checkpoint `
-Function ${Function:Install-PoshGit} `
-CheckpointName 'InstallPoshGit' `
-SkipMessage 'PoshGit already installed'
Use-Checkpoint `
-Function ${Function:Install-MonoDevelop} `
-CheckpointName 'InstallMonoDevelop' `
-SkipMessage 'MonoDevelop already installed'
# cinst poshgit
# cinst dotpeek
# re-enable chocolatey default confirmation behaviour
Use-Checkpoint -Function ${Function:Disable-ChocolateyFeatures} -CheckpointName 'DisableChocolatey' -SkipMessage 'Chocolatey features already configured'
# install chocolatey as last choco package
choco install chocolatey --limitoutput
# set HOME to user profile for git
[Environment]::SetEnvironmentVariable("HOME", $env:UserProfile, "User")
# rerun windows update after we have installed everything
Write-BoxstarterMessage "Windows update..."
Install-OsUpdates
Clear-Checkpoints
choco install visualstudio2012wdx -y
choco install dotnet3.5 -y
$Boxstarter.RebootOk = $true
$Boxstarter.NoPassword = $false
$Boxstarter.AutoLogin = $true
$checkpointPrefix = 'BoxStarter:Checkpoint:'
function Get-CheckpointName {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName
)
return "$checkpointPrefix$CheckpointName"
}
function Set-Checkpoint {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName,
[Parameter(Mandatory = $true)]
[string]
$CheckpointValue
)
$key = Get-CheckpointName $CheckpointName
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Machine") # for reboots
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Process") # for right now
}
function Use-Checkpoint {
param(
[string]
$CheckpointName,
[string]
$SkipMessage,
[scriptblock]
$Function
)
$checkpoint = Get-Checkpoint -CheckpointName $CheckpointName
if (-not $checkpoint) {
$Function.Invoke($Args)
Set-Checkpoint -CheckpointName $CheckpointName -CheckpointValue 1
}
else {
Write-BoxstarterMessage $SkipMessage
}
}
function Get-Checkpoint {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName
)
$key = Get-CheckpointName $CheckpointName
[Environment]::GetEnvironmentVariable($key, "Process")
}
function Clear-Checkpoints {
$checkpointMarkers = Get-ChildItem Env: | Where-Object { $_.name -like "$checkpointPrefix*" } | Select-Object -ExpandProperty name
foreach ($checkpointMarker in $checkpointMarkers) {
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Machine")
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Process")
}
}
function InitialReboot {
$CheckpointName = 'InitialReboot'
$Function = ${Function:Invoke-Reboot}
$SkipMessage = 'Already Rebooted'
$checkpoint = Get-Checkpoint -CheckpointName $CheckpointName
if (-not $checkpoint) {
Set-Checkpoint -CheckpointName $CheckpointName -CheckpointValue 1
$Function.Invoke($Args)
}
else {
Write-BoxstarterMessage $SkipMessage
}
}
function Install-OsUpdates {
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
if (Test-PendingReboot) { Invoke-Reboot }
}
function Update-ChocoPackages {
choco upgrade all -y
if (Test-PendingReboot) { Invoke-Reboot }
}
function Install-VisualStudio2017 {
choco install visualstudio2017community --limitoutput
Update-Path
}
function Install-PoshGit {
cinst poshgit
}
function Install-GitCredentialWinstore {
cinst git-credential-winstore
}
function Update-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") `
+ ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Set-RegionalSettings {
&"$env:windir\system32\tzutil.exe" /s "Central Standard Time"
}
function Enable-ChocolateyFeatures {
choco feature enable --name=allowGlobalConfirmation
}
function Disable-ChocolateyFeatures {
choco feature disable --name=allowGlobalConfirmation
}
function Install-ClassicShell {
choco install classic-shell
}
Use-Checkpoint `
-Function ${Function:Set-RegionalSettings} `
-CheckpointName 'RegionalSettings' `
-SkipMessage 'Regional settings are already configured'
Set-WindowsExplorerOptions -EnableShowFileExtensions
Enable-RemoteDesktop
Use-Checkpoint `
-Function ${Function:Install-ClassicShell} `
-CheckpointName 'InstallClassicShell' `
-SkipMessage 'Classic Shell already installed'
Use-Checkpoint `
-Function ${Function:Enable-ChocolateyFeatures} `
-CheckpointName 'IntialiseChocolatey' `
-SkipMessage 'Chocolatey features already configured'
# cinst git-credential-winstore
Use-Checkpoint `
-Function ${Function:Install-GitCredentialWinstore} `
-CheckpointName 'InstallGitCredentialWinstore' `
-SkipMessage 'GitCredentialWinstore already installed'
Use-Checkpoint `
-Function ${Function:Install-PoshGit} `
-CheckpointName 'InstallPoshGit' `
-SkipMessage 'PoshGit already installed'
Use-Checkpoint `
-Function ${Function:Install-VisualStudio2017} `
-CheckpointName 'InstallVisualStudio2017' `
-SkipMessage 'VisualStudio2017 already installed'
# cinst poshgit
# cinst dotpeek
# re-enable chocolatey default confirmation behaviour
Use-Checkpoint `
-Function ${Function:Disable-ChocolateyFeatures} `
-CheckpointName 'DisableChocolatey' `
-SkipMessage 'Chocolatey features already configured'
# install chocolatey as last choco package
choco install chocolatey --limitoutput
# set HOME to user profile for git
[Environment]::SetEnvironmentVariable("HOME", $env:UserProfile, "User")
# make sure all choco installed packages are up to date -- can use this
# script to keep system completely updated
Use-Checkpoint `
-Function ${Function:Update-ChocoPackages} `
-CheckpointName 'Update Choco Packages' `
-SkipMessage 'Choco Packages already up to date'
# rerun windows update after we have installed everything
Write-BoxstarterMessage "Windows update..."
Install-OsUpdates
Disable-MicrosoftUpdate
Clear-Checkpoints
$Boxstarter.RebootOk = $true
$Boxstarter.NoPassword = $false
$Boxstarter.AutoLogin = $true
$checkpointPrefix = 'BoxStarter:Checkpoint:'
function Get-CheckpointName {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName
)
return "$checkpointPrefix$CheckpointName"
}
function Set-Checkpoint {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName,
[Parameter(Mandatory = $true)]
[string]
$CheckpointValue
)
$key = Get-CheckpointName $CheckpointName
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Machine") # for reboots
[Environment]::SetEnvironmentVariable($key, $CheckpointValue, "Process") # for right now
}
function Use-Checkpoint {
param(
[string]
$CheckpointName,
[string]
$SkipMessage,
[scriptblock]
$Function
)
$checkpoint = Get-Checkpoint -CheckpointName $CheckpointName
if (-not $checkpoint) {
$Function.Invoke($Args)
Set-Checkpoint -CheckpointName $CheckpointName -CheckpointValue 1
}
else {
Write-BoxstarterMessage $SkipMessage
}
}
function Get-Checkpoint {
param
(
[Parameter(Mandatory = $true)]
[string]
$CheckpointName
)
$key = Get-CheckpointName $CheckpointName
[Environment]::GetEnvironmentVariable($key, "Process")
}
function Clear-Checkpoints {
$checkpointMarkers = Get-ChildItem Env: | Where-Object { $_.name -like "$checkpointPrefix*" } | Select-Object -ExpandProperty name
foreach ($checkpointMarker in $checkpointMarkers) {
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Machine")
[Environment]::SetEnvironmentVariable($checkpointMarker, '', "Process")
}
}
function InitialReboot {
$CheckpointName = 'InitialReboot'
$Function = ${Function:Invoke-Reboot}
$SkipMessage = 'Already Rebooted'
$checkpoint = Get-Checkpoint -CheckpointName $CheckpointName
if (-not $checkpoint) {
Set-Checkpoint -CheckpointName $CheckpointName -CheckpointValue 1
$Function.Invoke($Args)
}
else {
Write-BoxstarterMessage $SkipMessage
}
}
function Install-OsUpdates {
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
if (Test-PendingReboot) { Invoke-Reboot }
}
function Update-ChocoPackages {
choco upgrade all -y
if (Test-PendingReboot) { Invoke-Reboot }
}
function Install-VboxGuest {
choco install virtualbox-guest-additions-guest.install
}
function Update-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") `
+ ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
function Set-RegionalSettings {
&"$env:windir\system32\tzutil.exe" /s "Central Standard Time"
}
function Enable-ChocolateyFeatures {
choco feature enable --name=allowGlobalConfirmation
}
function Disable-ChocolateyFeatures {
choco feature disable --name=allowGlobalConfirmation
}
Use-Checkpoint `
-Function ${Function:Set-RegionalSettings} `
-CheckpointName 'RegionalSettings' `
-SkipMessage 'Regional settings are already configured'
Use-Checkpoint `
-Function ${Function:Enable-ChocolateyFeatures} `
-CheckpointName 'IntialiseChocolatey' `
-SkipMessage 'Chocolatey features already configured'
Use-Checkpoint `
-Function ${Function:Install-VboxGuest} `
-CheckpointName 'InstallVboxGuest' `
-SkipMessage 'VboxGuest already installed'
# re-enable chocolatey default confirmation behaviour
Use-Checkpoint `
-Function ${Function:Disable-ChocolateyFeatures} `
-CheckpointName 'DisableChocolatey' `
-SkipMessage 'Chocolatey features already configured'
# install chocolatey as last choco package
choco install chocolatey --limitoutput
# set HOME to user profile for git
[Environment]::SetEnvironmentVariable("HOME", $env:UserProfile, "User")
# make sure all choco installed packages are up to date -- can use this
# script to keep system completely updated
Use-Checkpoint `
-Function ${Function:Update-ChocoPackages} `
-CheckpointName 'Update Choco Packages' `
-SkipMessage 'Choco Packages already up to date'
# rerun windows update after we have installed everything
Write-BoxstarterMessage "Windows update..."
Install-OsUpdates
Disable-MicrosoftUpdate
Clear-Checkpoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment