Search code examples
powershellvagrantvirtualbox

Unable to run Vagrant commands through PowerShell script in VirtualBox


I try to run these 2 commands in the end of big script in Windows 10 which is installed in VirtualBox:

#Navigate to folder where Vagrant file will be placed

CD "D:\VagrantBoxes\Win8"

#mount Windows box

vagrant init windows_81x64-enterprise_virtualbox_15.07.17.box

#run Vagrant

vagrant up

But I receive an error:

vagrant : The term 'vagrant' is not recognized as the name of a cmdlet,  function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At F:\Scripts\Install_Vagrant.ps1:3 char:1
+ vagrant up
+ ~~~~~~~
+ CategoryInfo          : ObjectNotFound: (vagrant:String) [],   CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

But I can run these commands via PowerShell and PowerShell ISE severally. Also, I don't know why, PowerShell is executed Vagrant commands with comment lines.


Solution

  • Try to replace vagrant with vagrant.exe