SOLVED: Console Extension Pack installation Powershell

Discussions related to using VirtualBox on Windows hosts.

SOLVED: Console Extension Pack installation Powershell

Postby ft systems gmbh » 30. Nov 2017, 14:01

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
ft systems gmbh
 
Posts: 2
Joined: 30. Nov 2017, 13:52

Re: SOLVED: Console Extension Pack installation Powershell

Postby socratis » 30. Nov 2017, 15:19

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.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 12746
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: SOLVED: Console Extension Pack installation Powershell

Postby ft systems gmbh » 3. Dec 2017, 14:59

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   Expand viewCollapse view
# 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
ft systems gmbh
 
Posts: 2
Joined: 30. Nov 2017, 13:52


Return to VirtualBox on Windows Hosts

Who is online

Users browsing this forum: No registered users and 22 guests