VirtualBox 前言
VirtualBox 是一款开源虚拟机软件。VirtualBox 是由德国 Innotek 公司开发,由Sun Microsystems公司出品的软件,使用Qt编写,在 Sun 被 Oracle 收购后正式更名成 Oracle VM VirtualBox。Innotek 以 GNU General Public License (GPL) 释出 VirtualBox,并提供二进制版本及 OSE 版本的代码。使用者可以在VirtualBox上安装并且执行Solaris、Windows、DOS、Linux、OS/2 Warp、BSD等系统作为客户端操作系统。已由甲骨文公司进行开发,是甲骨文公司xVM虚拟化平台技术的一部分。
download VirtualBox
VirtualBox | VirtualBox 历史版本下载 | VirtualBox扩展包 | 文档 |
download | download | download | 参考 |
PDF文档 |
前提条件
- 开启wmi,配置网卡,参考
- 默认服务器CPU虚拟化功能开启的,PC需要人工干预开启CPU虚拟化功能
创建一键部署VirtualBox
- 最终实现在线下载VirtualBox,VirtualBox扩展,安装VirtualBox,VirtualBox扩展,环境变量,开机启动VirtualBox,环境依赖安装net,vc库,删除下载的文件及临时目录。
- c:\VirtualBox # VirtualBox安装目录位置,可以根据自己的实际目录和磁盘进行更改
- 测试环境在Windows Server 2019
- PC或者服务器开启CPU虚拟化技术
- 依赖VisualC++ ,所有包含历史版下载
powershell-install-virtualbox.ps1
<# Powershell Install virtualbox
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+ _____ _____ _ _ _ +
+ | __ \ / ____| | | | |+
+ | |__) |____ _____ _ _| (___ | |__ ___| | |+
+ | ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | |+
+ | | | (_) \ V V / __/ | ____) | | | | __/ | |+
+ |_| \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++
# Powershell Install virtualbox
# .\powershell-install-virtualbox.ps1
#>
$drive="c:"
$virtualbox_temporary="virtualbox_temporary"
$virtualbox="VirtualBox"
$virtualbox_exe="VirtualBox-7.0.8-156879-Win.exe"
$vc_redist_64="vc_redist.x64.exe"
$vc_redist_86="vc_redist.x86.exe"
$VirtualBox_Extension_Pack="Oracle_VM_VirtualBox_Extension_Pack-7.0.8-156879.vbox-extpack"
Write-Host "Create a directory for storing virtualbox temporary" -ForegroundColor Green
New-Item -ItemType Directory $drive\$virtualbox_temporary
$virtualbox_related_download = @(
"https://download.virtualbox.org/virtualbox/7.0.8/$virtualbox_exe",
"http://download.virtualbox.org/virtualbox/7.0.8/$VirtualBox_Extension_Pack",
"https://aka.ms/vs/17/release/$vc_redist_64",
"https://aka.ms/vs/17/release/$vc_redist_86"
)
foreach ($url in $virtualbox_related_download) {
$fileName = Split-Path $url -Leaf
$filePath = Join-Path $drive\$virtualbox_temporary $fileName
Invoke-WebRequest -Uri $url -OutFile $filePath
}
Write-Host "install NET-Framework 3.5 & 4.7" -ForegroundColor Green
#Get-WindowsFeature *NET*
Install-WindowsFeature -Name NET-Framework-Features -IncludeAllSubFeature
Install-WindowsFeature -Name NET-Framework-45-Features -IncludeAllSubFeature
Write-Host "install vc_redist x86 x64" -ForegroundColor Green
Start-Process -FilePath "$drive\$virtualbox_temporary\$vc_redist_64" -ArgumentList {/q /install} -Wait
Start-Process -FilePath "$drive\$virtualbox_temporary\$vc_redist_86" -ArgumentList {/q /install} -Wait
Write-Host "install virtualbox" -ForegroundColor Green
Start-Process -FilePath $drive\$virtualbox_temporary\$virtualbox_exe -ArgumentList "--silent", "--msiparams", "INSTALLDIR=`"c:\VirtualBox`"" -Wait
Write-Host "Create virtualbox environment variables" -ForegroundColor Green
$env:path += ";$drive\$virtualbox"
setx PATH $env:path /M
Write-Host "VirtualBox_Extension_Pack extension install" -ForegroundColor Green
echo "Y" | VBoxManage extpack install --replace $drive\$virtualbox_temporary\$VirtualBox_Extension_Pack
Write-Host "VirtualBox_Extension_Pack check" -ForegroundColor Green
VBoxManage list extpacks
Write-Host "bootstrap VirtualBox" -ForegroundColor Green
Start-Process schtasks {/create /tn VirtualBox /tr c:\VirtualBox\VirtualBox.exe /sc ONLOGON} -Verb runas
Write-Host "Delete related virtualbox_temporary installation packages and temporary directories" -ForegroundColor Green
Remove-Item -Path "$drive\$virtualbox_temporary\*.exe", "$drive\$virtualbox_temporary" -Recurse -Force
执行安装
.\powershell-install-virtualbox.ps1
结果输出展示
命令行打开appwiz.cpl程序和功能查看VirtualBox.exeVirtualBox.exe是否安装
powershell 全局打开 VirtualBox
VirtualBox.exe