File: install_virtualbox.ps1

package info (click to toggle)
vagrant 2.2.14%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,800 kB
  • sloc: ruby: 97,301; sh: 375; makefile: 16; lisp: 1
file content (37 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Param(
    [Parameter(Mandatory=$True)]
    [string]$path
)

# Stop on first error
$ErrorActionPreference = "Stop"

# Make the path complete
$path = Resolve-Path $path

# Determine if this is a 64-bit or 32-bit CPU
$architecture="x86"
if ((Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture -eq "64-bit") {
    $architecture = "amd64"
}

# Extract the contents of the installer
Start-Process -FilePath $path `
    -ArgumentList ('--extract','--silent','--path','.') `
    -Wait `
    -NoNewWindow

# Find the installer
$matches = Get-ChildItem | Where-Object { $_.Name -match "VirtualBox-.*_$($architecture).msi" }
if ($matches.Count -ne 1) {
    Write-Host "Multiple matches for VirtualBox MSI found: $($matches.Count)"
    exit 1
}
$installerPath = Resolve-Path $matches[0]

# Run the installer
Start-Process -FilePath "$($env:systemroot)\System32\msiexec.exe" `
    -ArgumentList "/i `"$installerPath`" /qn /norestart /l*v `"$($pwd)\install.log`"" `
    -Verb RunAs `
    -Wait `
    -WorkingDirectory "$pwd"