help with start-vm

Apr 1, 2011 at 10:45 AM
Edited Apr 1, 2011 at 10:46 AM



forgive me if i am missing something obvious, this is my first attempt at powershell scripting. i have the following script to shutdown a vm, export and then start the machine backup.

Import-Module "c:\Program Files\modules\Hyperv"

Get-VM -server server1 -vm vm1 | invoke-vmshutdown -force

Export-VM -VM vm1 -Path "c:\temp\vm1" -CopyState -wait

Get-VM -server server1 -vm vm1 | Start-VM

the script shuts down the virtual machine and creates the export correctly but doesn't start the machine backup. there are no errors and the script seems to pause at "Get-VM -server server1 -vm vm1 | Start-VM" if i hit the enter key the script continues and the machine starts up.

I need the script to continue automatically as i intend to schedule this to run overnight.

any help would be greatly appreciated