Repairing trust relationship in azure Windows VM using Serial console

There is going to be some times that you may restore a VM from a snapshot and the vm effectively is crashed its relationship with the domain since the snapshot was maybe performed long ago

In cases like this whether Remote desktop may not be available we should be able to re-join the machine using wmi queries in the azure vm console . In my case I have a set of policies that for security reasons Local Admin cannot remote into a VM using remote desktop wich creates a pickle when restoring VMS from snapshots.

Use the Serial console option azure to connect into the vm

Run cmd.exe

ch -si 1 ( channel 1 )

$computer = Get-WmiObject Win32_ComputerSystem
$computer.UnjoinDomainOrWorkGroup(“LocaladminPassword”, “LocalUser”, 0)
Restart-Computer -Force

Now you should be able to re-join the VM into the domain using remote desktop

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.