2017-11-10 14:33:00 -0500 EST

Pulling the plug on Windows (to rejoin a VM to the domain)

A Windows computer hosted as a Linux KVM guest has fallen off the domain? Not a big deal.

  1. Virtually disconnect the network cable from the running VM.
  2. Connect to the guest console, and log in as Administrator.
  3. Run a PowerShell command on the guest.
  4. Reconnect the guest’s network cable.

On the hypervisor, find the name of the virtual network interface used by the guest:

# virsh domiflist myvm
Interface  Type       Source     Model       MAC
vnet1      bridge     br0        virtio      52:54:00:6c:4c:b6

Disconnect the virtual network cable:

# virsh domif-setlink myvm vnet1 down
Device updated successfully

# virsh domif-getlink myvm vnet1
vnet1 down

Connect to the VM console:

# virt-viewer myvm

Log into the VM as Administrator (or a lesser account with sufficient privileges), and run this PowerShell command:

PS C:\> Reset-ComputerMachinePassword -Server -Credential (Get-Credential)

(The Add-Computer cmdlet may be useful in other circumstances.)

Plug the network cable back into the VM:

# virsh domif-setlink myvm vnet1 up
Device updated successfully

# virsh domif-getlink myvm vnet1
vnet1 up

Done. The VM should be back on the domain again.

#libvirt #powershell

⬅ Older Post Newer Post ➡