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.
- Virtually disconnect the network cable from the running VM.
- Connect to the guest console, and log in as Administrator.
- Run a PowerShell command on the guest.
- 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 domaincontroller.contoso.com -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