Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Last active May 10, 2025 03:01
Show Gist options
  • Save NotYusta/d63648828d22ce2c5bf8b4bdff4df0b6 to your computer and use it in GitHub Desktop.
Save NotYusta/d63648828d22ce2c5bf8b4bdff4df0b6 to your computer and use it in GitHub Desktop.
QEMU GUEST WINDOWS SCRIPTS
// All the commands can only be run if qemu guest agent is installed.
// Automatic resize - C Drive can only be resized when the recovery partition is deleted.
qm guest exec <vm-id> -- powershell -Command "Resize-Partition -DriveLetter C -Size (Get-PartitionSupportedSize -DriveLetter C).SizeMax"
// Automatic IPv4 network setup
qm guest exec <vm-id> netsh interface ipv4 set address name="Ethernet" static <ipv4> <ip-subnet> <ip-gateway>
// Automatic IPv4 DNS Setup
qm guest exec <vm-id> -- cmd.exe /c "netsh interface ipv4 add dns name=\"Ethernet\" 1.1.1.1 index=1 & netsh interface ipv4 add dns name=\"Ethernet\" 8.8.8.8 index=2"
// Automatic User Password reset
qm guest passwd <vm-id> Administrator --password "<passwd>"
// pretty much all enough for vps purposes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment