+5 votes
426 views
Force Off Hyper-V PowerShell Virtual Machine

in Virtualization by (552k points)
reopened | 426 views

1 Answer

+3 votes
Best answer

How to force a virtual machine to shut down in Hyper-V

Working with virtual machines in Hyper-V is an issue that involves a global control of numerous functionalities that range from cloning machines to linking services between the physical and virtual parts. We must understand that Hyper-V, being its own and integrated into Windows , by default supports Microsoft's own systems such as:

  • Windows 7/8/10
  • Windows Server 2012/2016/2019

This does not mean that it is possible to install and test other systems such as Linux , but in this case being 100% non-compatible systems. It can lead to errors being the non-disconnection of the virtual machine one of them and this make the machine processes remain active and thereby shutting down..

image

If we try to shut down the virtual machine from the interface, it will simply be frozen with the status "Shutting down" and if a stop-vm "MV" is executed from the console -Force simply fails. If this is your case, TechnoWikis has thought of you because it will give you the solution to correct this error in an integral way.

How to force a virtual machine to shut down in Hyper-V


Step 1

The first step will be to identify the GUID of the virtual machine, for this we access Windows PowerShell as administrators and execute the following:
 get-vm | ft VMName, VMid 
Step 2

This will result in the name of the virtual machine and its ID: image
Step 3

The ID must be copied and then make use of the following syntax with which it seeks to know the processes opened on the server linked to that particular machine:
 tasklist / fi "username eq" ID " 
Step 4

In this case we enter the following:
 tasklist / fi "username eq 4918fe46-7c2e-45c6-a953-f7a76f37a4ee 
image
Step 5

We can see the different services, but we will focus on the process “vmwp.exe” which takes care of the virtual machine boot.

This process has an associated PID, this PID must be stopped with the following syntax:

 taskkill / F / PID “pid” 
For our example we execute the following:
 taskkill / F / PID 4056 
image
Step 6

We see that the task is completed correctly, that will automatically stop the virtual machine and we can check it from the Hyper-V console in Windows 10: image

With this simple process it is possible to force the virtual machine to shut down in Hyper-V..


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Mar 10, 2020 in Virtualization by backtothefuture (552k points) | 594 views
+3 votes
1 answer
+5 votes
1 answer
asked Nov 3, 2022 in Virtualization by backtothefuture (552k points) | 81 views
+4 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users