I wrote a Powershell script that powers off a virtual machine, then copies the whole folder to external hard drive and then starts again the virtual machine.
My script works perfectly when I run it with Powershell ISE but after moving it to the host machine and scheduling it with task scheduler I run into errors that for me seem like permission errors.
The errors only appear on vboxmanage commands and not on regular cmdlets.
When trying to turn off the machine:
vboxmanage : VBoxManage.exe: error: Machine 'myVirtualMachine' is not currently running
At C:\Users\myUser\Documents\backup_scripts\myVirtualMachine\backup_script_myVirtualMachine.ps1:32 char:1
+ vboxmanage controlvm "myVirtualMachine" acpipowerbutto ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (VBoxManage.exe:...rrently running:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
When trying to turn the machine back on:
Waiting for VM "myVirtualMachine" to power on...
vboxmanage : VBoxManage.exe: error: Failed to open image 'D:\vbox\myVirtualMachine\myVirtualMachine.vdi' for writing due to wrong permissions (VERR_VD_IMAGE_READ_ONLY).
At C:\Users\myUser\Documents\backup_scripts\myVirtualMachine\backup_script_myVirtualMachine.ps1:52 char:1
+ vboxmanage startvm "myVirtualMachine" --type headless
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (VBoxManage.exe:...AGE_READ_ONLY).:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
VBoxManage.exe: error: AHCI: Failed to attach drive to Port0 (VERR_VD_IMAGE_READ_ONLY)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
The same errors appear if I run the script on Powershell as an administrator, without running Powershell as an admin everything works fine.
Running vboxmanage list runningvms
as an admin returns nothing but without running as an admin it returns all my running vms, as it should.
I have tried to run the script with highest priviledges on Task Scheduler and also with different user.
User contributions licensed under CC BY-SA 3.0