Add Flash Boot To Virtualbox Using Powershell

# Run powershell as administrator with cmd :

powershell "start powershell -verb runas"

# Add Path Virtualbox :

$existingPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
$newPath = $existingPath + ';C:\Program Files\Oracle\VirtualBox'
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')

# Check Environment Variables Virtualbox :

Get-ChildItem Env:

## Remove Path Virtualbox :

$existingPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
$newPath = $existingPath -replace ';C:\\Program Files\\Oracle\\VirtualBox', ''
[System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
Remove-Item -Path "Env:VBOX_MSI_INSTALL_PATH" -Force

# Make Directory Name Flash_boot :

mkdir $home\desktop\Flash_boot

# Go To Flash_boot Directory :

cd $home\desktop\Flash_boot

# Find The Physical Disk Index Number for USB Flash Drive :

Get-PhysicalDisk

# Create VMware Virtual Machine Disk to Flash Boot :

VBoxManage.exe internalcommands createrawvmdk -filename "UsbFlashDrive.vmdk" -rawdisk \\.\PhysicalDriveNUMBER_INDEX