diff --git a/VIRTBOX/vbox-discover-vms.ps1 b/VIRTBOX/vbox-discover-vms.ps1 new file mode 100644 index 0000000..0d964db --- /dev/null +++ b/VIRTBOX/vbox-discover-vms.ps1 @@ -0,0 +1,32 @@ +<# Discover virtualbox vms in dir and add them to gui #> +<# 2023.Nov kingneutron #> +<# Adapted from bash code #> + +# TODO EDITME for where your VMs live +D: +cd virtbox-vms + +$vbm="C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" +$result=get-childitem -Recurse *.vbox + +# $result.fullname +# D:\virtbox-vms\almalinux-test-centos-replacement-rhel8\almalinux-test-centos-replacement-rhel8.vbox + +foreach ($thisvm in $result.fullname) { + Write-Output $thisvm + & $vbm registervm $thisvm + +} + +& $vbm list vms +get-date +Write-Output "Recommended to run vbox-registerISOs now" + +<# +$result + Directory: D:\virtbox-vms\XPvm + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +-a--- 4/6/2023 2:39 PM 11447 XPvm.vbox +#> \ No newline at end of file diff --git a/VIRTBOX/vbox-registerISOs-2dirs.ps1 b/VIRTBOX/vbox-registerISOs-2dirs.ps1 new file mode 100644 index 0000000..63b3c86 --- /dev/null +++ b/VIRTBOX/vbox-registerISOs-2dirs.ps1 @@ -0,0 +1,42 @@ +<# Register known ISOs to virtualbox media manager #> +<# 2023.Nov kingneutron #> +<# Adapted from bash code #> +<# dont know why, but the Samba mount dir currently doesnt work #> + +$vmname="dummyisofinder" + +# xxx TODO EDITME +$vmdir="D:\virtbox-vms" +$isodir="D:\ISO" +$isodir2="Z:\ISO" # NAS / network mount + +$vbm="C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" + +& $vbm createvm --name "$vmname" --ostype 'Linux_64' --basefolder "$vmdir" --register +& $vbm modifyvm "$vmname" --description "NOTE this is just a temp VM used to conveniently register ISOs" + +& $vbm storagectl "$vmname" --name IDE --add ide --controller piix3 --portcount 2 --bootable on +#VBoxManage storageattach "$vmname" --storagectl IDE --port 0 --device 0 --type dvddrive --medium emptydrive #"X:\Folder\containing\the.iso" +#VBoxManage showvminfo "$vmname" + +cd $isodir + +# Define complex array +$result=[System.Collections.ArrayList]@() + +$result=get-childitem -Recurse *.iso + +cd $isodir2 +$result+=get-childitem -Recurse *.iso + +Write-Output $result.fullname +# brkpt + +foreach ($thisiso in $result.FullName) { + Write-Output "$thisiso" + & $vbm storageattach "$vmname" --storagectl IDE --port 0 --device 0 --type dvddrive --medium "$thisiso" +# VBoxManage modifyvm $vmname --dvd $PWD/${this} +} + +# eject +& $vbm storageattach "$vmname" --storagectl IDE --port 0 --device 0 --type dvddrive --medium emptydrive diff --git a/VIRTBOX/vbox-registerISOs.ps1 b/VIRTBOX/vbox-registerISOs.ps1 new file mode 100644 index 0000000..2acc2d1 --- /dev/null +++ b/VIRTBOX/vbox-registerISOs.ps1 @@ -0,0 +1,30 @@ +<# Register known ISOs to virtualbox media manager #> +<# 2023.Nov kingneutron #> +<# Adapted from bash code #> + +$vmname="dummyisofinder" + +# xxx TODO EDITME +$vmdir="D:\virtbox-vms" +$isodir="D:\ISO" + +$vbm="C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" + +& $vbm createvm --name "$vmname" --ostype 'Linux_64' --basefolder "$vmdir" --register +& $vbm modifyvm "$vmname" --description "NOTE this is just a temp VM used to conveniently register ISOs" + +& $vbm storagectl "$vmname" --name IDE --add ide --controller piix3 --portcount 2 --bootable on +#VBoxManage storageattach "$vmname" --storagectl IDE --port 0 --device 0 --type dvddrive --medium emptydrive #"X:\Folder\containing\the.iso" +#VBoxManage showvminfo "$vmname" + +cd $isodir +$result=get-childitem -Recurse *.iso + +foreach ($thisiso in $result.FullName) { + Write-Output $thisiso + & $vbm storageattach "$vmname" --storagectl IDE --port 0 --device 0 --type dvddrive --medium $thisiso +# VBoxManage modifyvm $vmname --dvd $PWD/${this} +} + +# eject +& $vbm storageattach "$vmname" --storagectl IDE --port 0 --device 0 --type dvddrive --medium emptydrive