title: Powershell - Calling VBoxManage.exe in a Script
body: <pre><code>[string]$VBoxManage="`"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe`""
  [string]$VMtoClone="`"C:\Users\someuser\VirtualBox VMs\CloneMe\CloneMe.vdi`""
  [string]$VMCloned="`"C:\Users\someuser\VirtualBox VMs\CloneMe\CloneMe_2.vdi`""
  [string]$cloneVDI="clonevdi"
  
  Write-Output ($VBoxManage + " " + $cloneVDI + " " + $VMtoClone + " " + $VMCloned)
  
  $commandtoinvoke=($VBoxManage + " " + $cloneVDI + " " + $VMtoClone + " " + $VMCloned)
  
  Invoke-Expression  $commandtoinvoke
  </code></pre>
  
  <p>I'm using a powershell script to clone a virtual machine. The issue I'm having this the following error:</p>
  
  <pre><code>Invoke-Expression : At line:1 char:53
  + "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonevdi "C:\Users\someuser\Virt ...
  +                                                     ~~~~~~~~
  Unexpected token 'clonevdi' in expression or statement.
  At line:10 char:1
  + Invoke-Expression  $commandtoinvoke
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ParserError: (:) [Invoke-Expression], ParseException
      + FullyQualifiedErrorId : UnexpectedToken,Microsoft.PowerShell.Commands.InvokeExpressionCommand
  </code></pre>
  
  <p>What does this error mean? How did I prevent it from happening?</p>