Skip to content

Conversation

@vyadavmsft
Copy link
Collaborator

When Stop-VM -Force times out or fails, VMs remain running and cause issues for subsequent operations. This implements a fallback mechanism.

Changes:

  • Wrap Stop-VM -Force in try-except to catch failures
  • On failure, attempt Stop-VM -TurnOff to forcefully power off the VM
  • Log warning when falling back to TurnOff
  • Log error and re-raise if both methods fail

This ensures VMs don't get stuck in running state when graceful shutdown hangs or times out, preventing leftover VMs on the server.

@vyadavmsft vyadavmsft requested a review from squirrelsc October 23, 2025 19:33
@squirrelsc
Copy link
Member

@LiliDeng LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants