Skip to content

Instantly share code, notes, and snippets.

@icetee
Last active June 17, 2017 06:51
Show Gist options
  • Save icetee/f089ce2c6008f9cb1a76 to your computer and use it in GitHub Desktop.
Save icetee/f089ce2c6008f9cb1a76 to your computer and use it in GitHub Desktop.
VirtualBox OSX modify vm extra params on Windows (Powershell)
# Code for Virtualbox 5.0.x:
# Code version: 1.1
function setExtraData {
# Set Virtual Machina name
$vm_name = $collection[$vm].Name
& "$location\VBoxManage.exe" modifyvm $vm_name --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
& "$location\VBoxManage.exe" setextradata $vm_name "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
& "$location\VBoxManage.exe" setextradata $vm_name "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
& "$location\VBoxManage.exe" setextradata $vm_name "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
& "$location\VBoxManage.exe" setextradata $vm_name "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
& "$location\VBoxManage.exe" setextradata $vm_name "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
}
function createOSXVM
{
param(
[Parameter()]
[ValidateNotNullOrEmpty()]
[String]$location="C:\Program Files\Oracle\VirtualBox\",
[String]$vm_name="OS X NAME",
[int]$vm = -1
)
# VirtualBox list
$vm_list = & "$location\VBoxManage.exe" list vms
# Add to Array and remove unnecessary chars
$trees = @($vm_list) -replace '({|})',''
# Add Virtual Machine list to array
$collection = @()
for($i = 0; $i -lt $trees.length; $i++)
{
$temp = New-Object System.Object
$temp | Add-Member -MemberType NoteProperty -Name "ID" -Value [$i]
$temp | Add-Member -MemberType NoteProperty -Name "Name" -Value $trees[$i].Split('"')[1].Trim()
$temp | Add-Member -MemberType NoteProperty -Name "UUID" -Value $trees[$i].Split('"')[2].Trim()
$collection += $temp
}
# Print Virtual Machine list
Write-Host "Choose between Virtual Machine"
Write-Host ($collection | Out-String)
# Read choosed Virtual Machine
[int]$vm = $( Read-Host "Please choose the Virtual Machine" )
switch -Regex ($vm)
{
-1 { "Please select correct/valid number!" }
"[0-9]" { setExtraData }
}
}
createOSXVM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment