Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# Usage: vb-reset-host-version-guestproperty.sh myvmname
VMNAME=$1
VBOXMANAGE="$(which vboxmanage)"
if [ -z "$VMNAME" ]; then
echo "Must provide name of VM."
exit 1
fi
# Find UUID
UUID="$($VBOXMANAGE list vms | grep -w $VMNAME | cut -d' ' -f2 | tr -d '{}')"
if [ -z "$UUID" ]; then
echo "No VM found with the name '$VMNAME'."
exit 1
fi
echo "Found UUID:$UUID"
# Set latest version
CURRENT_VERSION="$($VBOXMANAGE --version)"
GUESTPROPERTY_VERSION="$($VBOXMANAGE guestproperty get $UUID /VirtualBox/GuestAdd/Version | sed s/Value\:\ //g)"
if [ "$CURRENT_VERSION" != "$GUESTPROPERTY_VERSION" ]; then
$VBOXMANAGE guestproperty set $UUID /VirtualBox/GuestAdd/Version "$CURRENT_VERSION"
echo "GuestProperty(/VirtualBox/GuestAdd/Version) updated to '$CURRENT_VERSION' from '$GUESTPROPERTY_VERSION'"
else
echo "Versions match: $CURRENT_VERSION"
fi
@NeMO84

This comment has been minimized.

Copy link
Owner Author

@NeMO84 NeMO84 commented Mar 10, 2019

@mluis7

This comment has been minimized.

Copy link

@mluis7 mluis7 commented Jul 14, 2020

Cool script! just fails on some distros due to vboxmanage name spelled VBoxManage.
Once that's fixed, works as expected.
For some reason it does not fix Vagrant version mismatch message
[default] GuestAdditions seems to be installed (6.0.22) correctly, but not running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.