Skip to content

Instantly share code, notes, and snippets.

@SantiiRepair
Created October 25, 2024 05:04
Show Gist options
  • Save SantiiRepair/0393611227f5f80276aebefd4f16264c to your computer and use it in GitHub Desktop.
Save SantiiRepair/0393611227f5f80276aebefd4f16264c to your computer and use it in GitHub Desktop.
GPUHyper
$vm = "VMNAME"
Remove-VMGpuPartitionAdapter -VMName $vm
Add-VMGpuPartitionAdapter -VMName $vm
Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionVRAM 1
Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionVRAM 11
Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionVRAM 10
Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionEncode 1
Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionEncode 11
Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionEncode 10
Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionDecode 1
Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionDecode 11
Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionDecode 10
Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionCompute 1
Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionCompute 11
Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionCompute 10
Set-VM -GuestControlledCacheTypes $true -VMName $vm
Set-VM -LowMemoryMappedIoSpace 1Gb -VMName $vm
Set-VM -HighMemoryMappedIoSpace 32GB -VMName $vm
Start-VM -Name $vm
$vm = "VMNAME"
$systemPath = "C:\Windows\System32\"
$driverPath = "C:\Windows\System32\DriverStore\FileRepository\"
# check if script is admin
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if( $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) {
# do we need guest vm privs? enable it
Get-VM -Name $vm | Get-VMIntegrationService | ? {-not($_.Enabled)} | Enable-VMIntegrationService -Verbose
# aggregate and copy files to driverstore
$localDriverFolder = ""
Get-ChildItem $driverPath -recurse | Where-Object {$_.PSIsContainer -eq $true -and $_.Name -match "nv_dispi.inf_amd64_*"} | Sort-Object -Descending -Property LastWriteTime | select -First 1 |
ForEach-Object {
if ($localDriverFolder -eq "") {
$localDriverFolder = $_.Name
}
}
Write-Host $localDriverFolder
Get-ChildItem $driverPath$localDriverFolder -recurse | Where-Object {$_.PSIsContainer -eq $false} |
Foreach-Object {
$sourcePath = $_.FullName
$destinationPath = $sourcePath -replace "^C\:\\Windows\\System32\\DriverStore\\","C:\Temp\System32\HostDriverStore\"
Copy-VMFile $vm -SourcePath $sourcePath -DestinationPath $destinationPath -Force -CreateFullPath -FileSource Host
}
# get all files related to NV*.* in system32
Get-ChildItem $systemPath | Where-Object {$_.Name -like "NV*"} |
ForEach-Object {
$sourcePath = $_.FullName
$destinationPath = $sourcePath -replace "^C\:\\Windows\\System32\\","C:\Temp\System32\"
Copy-VMFile $vm -SourcePath $sourcePath -DestinationPath $destinationPath -Force -CreateFullPath -FileSource Host
}
Write-Host "Success! Please go to C:\Temp and copy the files where they are expected within the VM."
} else {
Write-Host "This PowerShell Script must be run with Administrative Privileges or nothing will work."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment