Update SetupVM.ps1

This commit is contained in:
James Stringer 2021-06-23 17:15:23 +02:00 committed by GitHub
parent 03d65cfcac
commit 9a537800fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,13 +4,14 @@ param(
[string]$VMName = "GPU-P", [string]$VMName = "GPU-P",
[int64]$MemoryAmount = 8GB, [int64]$MemoryAmount = 8GB,
[int]$CPUCores = 4, [int]$CPUCores = 4,
[Parameter(Mandatory=$true)][string]$WindowsISOPath = "" [string]$WindowsISOPath = "C:\Users\james\Downloads\Windows10_InsiderPreview_Client_x64_en-us_21354.iso"
) )
New-vhd -SizeBytes $HDDSize -Path "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\$VMName.vhdx" -Dynamic New-vhd -SizeBytes $HDDSize -Path "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\$VMName.vhdx" -Dynamic
New-VM -Name $VMName -MemoryStartupBytes $MemoryAmount -VHDPath "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\$VMName.vhdx" -Generation 2 -SwitchName "Default Switch" New-VM -Name $VMName -MemoryStartupBytes $MemoryAmount -VHDPath "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\$VMName.vhdx" -Generation 2 -SwitchName "Default Switch"
Set-VM -Name $VMName -ProcessorCount $CPUCore -CheckpointType Disabled -LowMemoryMappedIoSpace 3GB -HighMemoryMappedIoSpace 32GB -GuestControlledCacheTypes $true Set-VM -Name $VMName -ProcessorCount $CPUCores -CheckpointType Disabled -LowMemoryMappedIoSpace 3GB -HighMemoryMappedIoSpace 32GB -GuestControlledCacheTypes $true -AutomaticStopAction ShutDown
Set-VMMemory -VMName $VMName -DynamicMemoryEnabled $false Set-VMMemory -VMName $VMName -DynamicMemoryEnabled $false
Add-VMDvdDrive -VMName $VMName -Path $ISOPath Add-VMDvdDrive -VMName $VMName -Path $WindowsISOPath
Set-VMFirmware -VMName $VMName -BootOrder $((Get-VMFirmware -VMName "GPU-P").BootOrder.Device | Where-Object name -like "DVD*"), $((Get-VMFirmware -VMName "GPU-P").BootOrder.Device | Where-Object name -like "Hard Drive*"), $((Get-VMFirmware -VMName "GPU-P").BootOrder.Device | Where-Object name -like "Network Adapter*")
} }
Function Get-VMGpuPartitionAdapterFriendlyName { Function Get-VMGpuPartitionAdapterFriendlyName {
@ -22,8 +23,6 @@ Function Get-VMGpuPartitionAdapterFriendlyName {
} }
function Assign-VMGPUPartitionAdapter { function Assign-VMGPUPartitionAdapter {
param( param(
[string]$VMName, [string]$VMName,
@ -38,5 +37,5 @@ param(
Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionCompute 0 -MaxPartitionCompute 1000000000 -OptimalPartitionCompute 1000000000 Set-VMGpuPartitionAdapter -VMName $VMName -MinPartitionCompute 0 -MaxPartitionCompute 1000000000 -OptimalPartitionCompute 1000000000
} }
Assign-VMGPUPartitionAdapter -GPUName "NVIDIA GeForce RTX 2060 SUPER" -VMName "GPU-P" #Assign-VMGPUPartitionAdapter -GPUName "NVIDIA GeForce RTX 2060 SUPER" -VMName "GPU-P"