none
How to detect if a VM is under some operation?

    Question

  • Say I want to migrate a Virtual machine, then is it possible to check, preferably using cmdlets, whether any other operation is going on on that VM say a clone or a checkpoint? I would like to check for that before I migrate the VM and by migrate I mean doing it myself my moving files using a script. Let me know if the question isn't clear and I can throw some more light on it. Thanks!
    Sunday, February 5, 2017 10:02 AM

Answers

All replies

  • Hello,

    You can use the following command to get the status of the VM, and based on the statue to decide the migration of VM.

    Get-VM -Name <VM Name> | fl status

    More information about this command, please see the article below.

    https://technet.microsoft.com/en-us/library/hh848479.aspx?f=255&MSPPError=-2147217396

    Best regards,
    Andy Liu

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, February 6, 2017 8:43 AM
  • Thanks Andy for the reply. The status field you are talking about, it does say "Creating checkpoint" when it is under checkpoint and at other times says "Operating normally" so this should work for me but I want to know can I reliably check the status ("Operating normally") and say that no operation is going on that VM? Can there be cases when some operation is going on and the status is still "Operating normally" or can there be cases when it is in some other state than "Operating normally" but no operation is going on that VM?

    Note: This is going to be done in a programmatic way so in the code I will have to check for the status to see if any operation is going on or not.

    • Edited by Ni- Tuesday, February 7, 2017 3:45 AM
    Tuesday, February 7, 2017 3:44 AM
  • Hello,

    You may check the OperationalStatus instead of Status. You can find the detailed descriptions for VM from the following links. These links are applied to Windows 2008, Windows 2012 and Windows 2016 separately.

    https://msdn.microsoft.com/en-us/library/cc136822%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

    https://msdn.microsoft.com/en-us/library/hh850116%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

    https://msdn.microsoft.com/en-us/library/mt167806(v=vs.85).aspx

    By the way, you can get the value of OperationalStatus by running the command below.

    Get-VM -Name <VM Name> | fl OperationalStatus

    or

    Get-VM -Name <VM Name> | fl *

    Best regards,

    Andy Liu


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Marked as answer by Ni- Wednesday, February 8, 2017 4:55 AM
    Wednesday, February 8, 2017 2:21 AM
  • This is really helpful Andy, thanks a lot!! I have marked this as the answer.

    Just as a side question, I don't think there is any way I could have reached the answer that you provided. I mean, I was trying to look for in the Get-Vm which value I could use and though I could see the "OperationalStatus" field, I couldn't have guessed if that is what I should use. I don't know how I could have reached the "Msvm_ComputerSystem" class and saw the description for "OperationalStatus", so do you have any pointers on which would be the first places to start to look for answers because clearly the Get-Vm technet page doesn't really provide any answers. Sorry for such a broad question but if you could provide me any pointers that would be helpful otherwise you have already provided me the answer I was looking for so thanks for that :)

    Wednesday, February 8, 2017 5:02 AM
  • Hello,

    Thank you.

    You may also refer to the following article, which lists the available status of VM. However, the article is relevant to SCVMM and Orchestrator.

    There is no Hyper-V relevant documents which describe the status of VM in more details.

    

    https://technet.microsoft.com/en-us/library/gg440691.aspx?f=255&MSPPError=-2147217396#BKMK_ConfigureGetVM

    https://technet.microsoft.com/en-us/library/hh830744.aspx

    Best regards,

    Andy Liu


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, February 8, 2017 5:46 AM