71.0k views
4 votes
Which PowerShell command is used to shut down and then restart a virtual machine (VM)?

Option 1: Restart-Computer -Force
Option 2: Stop-VM; Start-VM
Option 3: Shutdown-VM; Start-VM
Option 4: Restart-VM -Force

User Pritesh
by
7.4k points

1 Answer

7 votes

Final Answer:

The correct option to shut down and then restart a virtual machine (VM) using PowerShell is Shutdown-VM; Start-VM. Option C is the answer.

Step-by-step explanation:

The Shutdown-VM command is used to gracefully shut down a virtual machine, ensuring that all running processes are properly closed. After shutting down the VM, the Start-VM command is employed to restart it. This sequence of commands provides a controlled and orderly restart of the virtual machine.

Option 1 (Restart-Computer -Force) is a general computer restart command and may not be suitable for VMs. Option 2 (Stop-VM; Start-VM) directly stops and starts the VM without a proper shutdown. Option 4 (Restart-VM -Force) is a non-existent command for VM restart in PowerShell.

Option C is the answer.

User Alagris
by
7.4k points