Skip to content

Instantly share code, notes, and snippets.

@mefellows
Last active August 29, 2015 14:21
Show Gist options
  • Save mefellows/0c41391a8e5afb7394dc to your computer and use it in GitHub Desktop.
Save mefellows/0c41391a8e5afb7394dc to your computer and use it in GitHub Desktop.
Packer - Issue 48 repro
{
"builders": [ {
"type": "virtualbox-windows-ovf",
"name": "vagrantbox",
"source_path": "/Users/mfellows/Downloads//output-virtualbox-iso/packer-virtualbox-iso-1417096689.ovf",
"guest_additions_mode": "disable",
"headless":false,
"boot_wait":"15s",
"winrm_username": "vagrant",
"winrm_password": "vagrant",
"winrm_wait_timeout": "120s",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"2048"
],
[
"modifyvm",
"{{.Name}}",
"--vram",
"64"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"2"
]
]
}],
"provisioners": [
{
"type":"powershell",
"inline":["(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z938.msi','C:\\7zip.msi')"]
},
{
"type": "powershell",
"elevated_user": "vagrant",
"elevated_password": "vagrant",
"scripts": ["script.ps1"]
}]
}
# IC Server Installation
#
#
<# # Documentation {{{
.Synopsis
Installs CIC
#> # }}}
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false)][string] $User = 'vagrant',
[Parameter(Mandatory=$false)][string] $Password = 'vagrant',
# Note: This is different!!!!
#[Parameter(Mandatory=$false)][string] $InstallPath = 'C:\I3\IC',
[Parameter(Mandatory=$false)][string] $InstallSource = 'C:\',
[Parameter(Mandatory=$false)][string] $SourceDriveLetter = 'I',
[Parameter(Mandatory=$false)][switch] $Wait,
[Parameter(Mandatory=$false)][switch] $Reboot
)
Write-Output "Script started at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
$Now = Get-Date -Format 'yyyyMMddHHmmss'
#$Source_filename = "ICServer_2015_R2.msi"
$Source_filename = "7zip.msi"
$Product = 'Interaction Center Server 2015 R2'
if (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -eq $Product)
{
Write-Output "$Product is already installed"
}
else
{
Write-Output "Installing $Product"
$stop_watch = [Diagnostics.StopWatch]::StartNew()
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.UseShellExecute = $false
$psi.FileName = 'msiexec'
if ([Environment]::OSVersion.Version -ge (New-Object 'Version'6,0)) { $psi.Verb = "runas" }
$psi.WorkingDirectory = "C:\Windows\Temp"
$psi.Arguments = "/i `"${InstallSource}\${Source_filename}`" /qn /norestart REBOOT=ReallySuppress /l*v `"C:\Windows\Logs\icserver-${Now}.log`""
Write-Output "Arguments: [$($psi.Arguments)]"
Write-Output "Starting process"
$result = [System.Diagnostics.Process]::Start($psi)
Write-Output "process started"
Write-Output "waiting for process to exit"
while (! $result.WaitForExit(60000))
{
$elapsed = ''
if ($stop_watch.Elapsed.Days -gt 0) { $elapsed = " $($stop_watch.Elapsed.Days) days" }
if ($stop_watch.Elapsed.Hours -gt 0) { $elapsed = " $($stop_watch.Elapsed.Hours) hours" }
if ($stop_watch.Elapsed.Minutes -gt 0) { $elapsed = " $($stop_watch.Elapsed.Minutes) minutes" }
if ($stop_watch.Elapsed.Seconds -gt 0) { $elapsed = " $($stop_watch.Elapsed.Seconds) seconds" }
Write-Output "$Product is still installing after $elapsed"
}
$stop_watch.Stop()
$elapsed = ''
if ($stop_watch.Elapsed.Days -gt 0) { $elapsed = " $($stop_watch.Elapsed.Days) days" }
if ($stop_watch.Elapsed.Hours -gt 0) { $elapsed = " $($stop_watch.Elapsed.Hours) hours" }
if ($stop_watch.Elapsed.Minutes -gt 0) { $elapsed = " $($stop_watch.Elapsed.Minutes) minutes" }
if ($stop_watch.Elapsed.Seconds -gt 0) { $elapsed = " $($stop_watch.Elapsed.Seconds) seconds" }
Write-Output "$Product installed successfully in $elapsed (Exit: $($result.ExitCode))"
if ($result.ExitCode -ge 0)
{
Write-Output "Check the VM!"
Start-Sleep 900
}
exit $result.ExitCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment