Skip to content

Instantly share code, notes, and snippets.

@jsfag
Created August 28, 2022 10:41
Show Gist options
  • Save jsfag/a1d6c3431721a60d6388d48f81f84b15 to your computer and use it in GitHub Desktop.
Save jsfag/a1d6c3431721a60d6388d48f81f84b15 to your computer and use it in GitHub Desktop.
Enable and disable GPU partition (edit for your PCI addresses and VM name).
# Change to name of TARGET-VM.
$vm='win10'
# Change to PCI device location (💡 Location).
$Location = 'PCIROOT(0)#PCI(0301)#PCI(0000)#PCI(0000)#PCI(0000)'
Remove-VMAssignableDevice -LocationPath $locationPath -VMName $vm
Mount-VMHostAssignableDevice -LocationPath $locationPath
# Change to name of TARGET-VM.
$vm='win10'
# Change to PCI device location (💡 Location).
$Location = 'PCIROOT(0)#PCI(0301)#PCI(0000)#PCI(0000)#PCI(0000)'
# Enable CPU features.
Set-VM -GuestControlledCacheTypes $true -VMName $vm
# Host-Shutdown rule must be changed for the VM.
Set-VM -Name $vm -AutomaticStopAction TurnOff
# Change size to fit your requirements ("💡 Min required MMOU Space").
# (See https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/plan/plan-for-deploying-devices-using-discrete-device-assignment#mmio-space)
#Set-VM -LowMemoryMappedIoSpace 3Gb -VMName $vm # 32bit
Set-VM -HighMemoryMappedIoSpace 6Gb -VMName $vm # 64bit
# Dismount device
Dismount-VMHostAssignableDevice -LocationPath $Location
Dismount-VMHostAssignableDevice -force -LocationPath $Location
Add-VMAssignableDevice -LocationPath $Location -VMName $vm
# Try start the VM in Hyper-V manager.
# ❓ Starting fails with: "A hypervisor feature is not available to the user." ❓
# See: https://social.technet.microsoft.com/Forums/ie/en-US/a7c2940a-af32-4dab-8b31-7a605e8cf075/a-hypervisor-feature-is-not-available-to-the-user?forum=WinServerPreview
# Reboot host.
bcdedit /set hypervisoriommupolicy enable
Restart-Computer -Confirm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment