Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How run Stop-VM without confirmation and without -Force

$
0
0
When I run
Stop-VM -Name "VMNAME" -confirm:$false
I receive prompt for confirmation:
    Confirm
    Hyper-V cannot shut down virtual machine VMNAME because the Shutdown integration service is 
    unavailable. To avoid potential data loss, you can pause or save the state of the virtual machine. 
    The
    other option is to turn off the virtual machine, but data loss might occur.
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): N

    
But when I run the script (for example, cron), I do not want any interactive and pause on this team.
I would want that the command returned an error or does not return anything (and later deal with the result of the command), but does not stop the execution of waiting for a input in the console.
And I want an answer "No" to such a request (-Force I understand it gives the answer is always Yes).

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>