Run a script when a Hyper-V virtual machine is resumed after save

Rob Nicholson 51 Reputation points
2024-09-10T08:27:07.2866667+00:00

I'd like to run a PowerShell script within a Hyper-V virtual machine when the VM is re-started (not booted) after been saved. A scheduled task triggered off a specific event maybe but I can't spot anything related about re-start after save in the event logs. There are events written to the Hyper-V host but need the event to be triggered in the VM itself.

With VMware Workstation, this could be achieved using VMware Tools Scripts like resume-vm-default.bat. Not sure if Hyper-V integration services offers anything similar.

Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,695 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue 36,336 Reputation points Microsoft Vendor
    2024-09-11T01:22:55.4133333+00:00

    Hi Rob Nicholson,

    Thanks for your post.

    You can try attaching a task to the event 18596 which is generated when a VM is restored successfully. This event is logged under Applications and Services Logs > Microsoft > Windows > Hyper-V-Worker in Event Viewer.

    User's image

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.