SOLVED: Console Extension Pack installation Powershell

Discussions related to using VirtualBox on Windows hosts.
Post Reply
ft systems gmbh
Posts: 2
Joined: 30. Nov 2017, 13:52

SOLVED: Console Extension Pack installation Powershell

Post by ft systems gmbh »

Hi together

I've written a Powershellscript to Install the Extension Pack and want to share it here.
Unfotunatelly this message comes: "You must be a member for 1 days and have 1 posts before you can post u r l." (Because I have some U R L to refer)
Even the word "U R L" is not allowed for the first Post. Thats why I write it with spaces.

So, I create my first post with this and publish the script tomorrow. :wink:

Kind Regards
Michael
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: SOLVED: Console Extension Pack installation Powershell

Post by socratis »

Don't post the URL, post the instructions here. You never know when your hosting site might go down. Again, please post the instructions here, not in a 3rd party site. Thank you.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ft systems gmbh
Posts: 2
Joined: 30. Nov 2017, 13:52

Re: SOLVED: Console Extension Pack installation Powershell

Post by ft systems gmbh »

Hi together

@socratis: I always wanted to post the solution, not just a link. But for documentation reason (source links of some code snippets) my post contains URL's. Sorry when I was unspecific. :-)

Based on this page viewtopic.php?f=7&t=44337 I've written a Powershellscript.
I've written some potential improvements in the script. (See "The following features are not implemented yet.") Feel free to implement and share them.

Have fun.

Kind Regards
Michael

Code: Select all

# Scriptname: 171130_virtualbox_extpack-vALL-both-mui.ps1
# 30.11.2017, Michael Nydegger, http://www.michael-nydegger.ch
# Titel: Download and install proper extension pack for Virtualbox
# Description: This script downloads the proper VirtualBox ExtensionPack.
#
# IMPORTENT
# Oracle VM VirtualBox Extension Pack is only for personal and evaluation use!
# See https://www.virtualbox.org/wiki/VirtualBox_PUEL
#
# The following features are not implemented yet. Feel free to implement and share it:
# - Check if downloadfile exists before downloading. Line 40
# - Check if the current Version of Extension pack is installed. if yes -> abort installation
# - Check if VirtualBox Extension Pack was successfully installed

# Testing
# -------
# Tested as followed:
# - Install on Virtualbox Version 5.2.2r119230
# - Install on Virtualbox Version 5.1.30
# - Install on Virtualbox Version 5.1.30. Executed this script. Updated Virtualbox to 5.2.2r119230. Run this script again.


# Manual of "VBoxManage.exe": https://www.virtualbox.org/manual/ch08.html


# Check if "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" exists aka Virtualbox is installed
# Source: https://www.windowspro.de/script/test-path-powershell-pruefen-ob-eine-datei-existiert

if(Test-Path "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"){

	# Get version of the installed VirtualBox
	$VBOX_VERSION_PLAIN = & "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" -v

	# Cut string of version
	# Source: https://stackoverflow.com/questions/5203730/cut-off-text-in-string-after-before-seperator-in-powershell
	# Get version without number after letter "r"
	$VBOX_VERSION_CUT_BEFORE = $VBOX_VERSION_PLAIN.Substring(0, $VBOX_VERSION_PLAIN.IndexOf("r"))
	# Get number after letter "r"
	$VBOX_VERSION_CUT_AFTER = $VBOX_VERSION_PLAIN.Substring($VBOX_VERSION_PLAIN.IndexOf("r")+1)

	# Create Filename to download
    # Example filename: Oracle_VM_VirtualBox_Extension_Pack-5.1.30-118389.vbox-extpack  
	$VBOX_FILENAME = "Oracle_VM_VirtualBox_Extension_Pack-" + $VBOX_VERSION_CUT_BEFORE + "-" + $VBOX_VERSION_CUT_AFTER + ".vbox-extpack"

	# Create full downloadpath
	$VBOX_DOWNLOADPATH = "http://download.virtualbox.org/virtualbox/" + $VBOX_VERSION_CUT_BEFORE + "/" + $VBOX_FILENAME

	# Check if link exist
	# Source: https://gist.github.com/hrwgc/7455343
	# not implemented yet. Feel free to complete


	# Download file
	wget $VBOX_DOWNLOADPATH -OutFile $VBOX_FILENAME
	
	# Install the downloaded package
    # "--replace" removes old versions first.
    # Accept License. Source:
    # https://forums.virtualbox.org/viewtopic.php?f=6&t=82761#p399415
    # https://www.virtualbox.org/ticket/16674
	echo y | & "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" extpack install --replace $VBOX_FILENAME
	
	
	# "Used to remove temporary files and directories that may have been left behind if a previous install or uninstall command failed." - Copied from https://www.virtualbox.org/manual/ch08.html
	& "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" extpack cleanup
	
    # Delete downloaded file
    Remove-Item $VBOX_FILENAME -Force


	$EXITMESSAGE = "Installation finished"
	$EXITCODE = 0

	}
else{
	$EXITMESSAGE = "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe not found. Probably Virtualbox is not installed."
	$EXITCODE = 1
	}
Write-Host $EXITMESSAGE
exit $EXITCODE
Post Reply