Virtualbox headless install Windows from CLI

So you’re wondering how to create and manage a Virtualbox VM from command line (CLI)? Here are the steps I used for a Windows installation.
Windows 8.1 Pro – legal download from http://windows.microsoft.com/en-us/windows-8/create-reset-refresh-media
Obviously you need to buy an activation key from somewhere.

Before proceeding, you might want to ln -s /usr/bin/VBoxManage /usr/bin/vboxmanage. But if you prefer to do complicated acrobatics with your fingers, then replace with VBoxManage all commands below.

vboxmanage list ostypes
vboxmanage createvm --name windows81 --ostype Windows81_64 --basefolder /home/virtualbox/ --register
vboxmanage modifyvm windows81 --memory 2048 --vram 128 --acpi on --ioapic on --cpus 1 --pae on --hwvirtex on --cpuexecutioncap 85
vboxmanage storagectl windows81 --name "SATA Controller" --add sata --hostiocache on --bootable on
vboxmanage storagectl windows81 --name "IDE Controller" --add ide --bootable on
vboxmanage createhd --filename /home/virtualbox/windows81/windows81.vdi --size 20000 --format VDI
vboxmanage storageattach windows81 --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /home/virtualbox/windows81/windows81.vdi
vboxmanage storageattach windows81 --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium <path to Windows 8.1 install iso>


Add a bridged network (skip if you don’t need):
vboxmanage modifyvm windows81 --nic1 none
vboxmanage modifyvm windows81 --nic1 bridged eth0 --cableconnected1 on

*Enable (password protected) VRDE for remote connection:
vboxmanage modifyvm windows81 --vrde on --vrdeaddress 0.0.0.0 --vrdeauthtype external --vrdemulticon on
vboxmanage internalcommands passwordhash <type password>
vboxmanage setextradata windows81 "VBoxAuthSimple/users/<type username>" <enter password hash from previous command>

vboxmanage startvm windows81 --type headless

win8-virtualbox

*NB: You need the VirtualBox Extension Pack for VRDE. Download from https://www.virtualbox.org/wiki/Downloads.
wget http://download.virtualbox.org/virtualbox/4.3.20/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack
vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack<a href="https://blog.adminfactory.net/wp-content/uploads/2015/02/win8-virtualbox.jpg">

Other commands:
vboxmanage controlvm windows81 poweroff
vboxmanage storageattach windows81 --storagectl "IDE Controller" --port 0 --device 0 --medium emptydrive

A good idea would be to install the Guest Additions after you complete the Windows installation, as it adds a lot of improvements.
vboxmanage storageattach windows81 --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso
and install from within Windows