From 11648360a94fb946a8fbdf80976bff3b5a91e9c1 Mon Sep 17 00:00:00 2001 From: James Stringer <38541878+jamesstringerparsec@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:19:04 +0100 Subject: [PATCH] Set VM configuration version to maximum --- CopyFilesToVM.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index 41825d3..7b0ae14 100644 --- a/CopyFilesToVM.ps1 +++ b/CopyFilesToVM.ps1 @@ -4297,8 +4297,9 @@ param( [string]$autologon ) Modify-AutoUnattend -username "$username" -password "$password" -autologon $autologon -hostname $VMName -UnattendPath $UnattendPath + $MaxAvailableVersion = (Get-VMHostSupportedVersion).Version | Select-Object -Last 1 Convert-WindowsImage -SourcePath $SourcePath -Edition $Edition -VHDFormat $Vhdformat -VHDPath $VhdPath -DiskLayout $DiskLayout -UnattendPath $UnattendPath -GPUName $GPUName -Team_ID $Team_ID -Key $Key -SizeBytes $SizeBytes| Out-Null - New-VM -Name $VMName -MemoryStartupBytes $MemoryAmount -VHDPath $VhdPath -Generation 2 -SwitchName "Default Switch" | Out-Null + New-VM -Name $VMName -MemoryStartupBytes $MemoryAmount -VHDPath $VhdPath -Generation 2 -SwitchName "Default Switch" -Version $MaxAvailableVersion | Out-Null Set-VM -Name $VMName -ProcessorCount $CPUCores -CheckpointType Disabled -LowMemoryMappedIoSpace 3GB -HighMemoryMappedIoSpace 32GB -GuestControlledCacheTypes $true -AutomaticStopAction ShutDown Set-VMMemory -VMName $VMName -DynamicMemoryEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true