From 7c42aa892e1edb4aa86c437124ab232fc5155518 Mon Sep 17 00:00:00 2001 From: 841973620 <841973620@qq.com> Date: Mon, 3 Apr 2023 01:30:20 +0800 Subject: [PATCH 1/3] Update PreChecks.ps1 add check support for Windows Server --- PreChecks.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PreChecks.ps1 b/PreChecks.ps1 index fe8a611..d856e94 100644 --- a/PreChecks.ps1 +++ b/PreChecks.ps1 @@ -15,11 +15,11 @@ Function Get-DesktopPC Function Get-WindowsCompatibleOS { $build = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -if ($build.CurrentBuild -ge 19041 -and ($($build.editionid -like 'Professional*') -or $($build.editionid -like 'Enterprise*') -or $($build.editionid -like 'Education*'))) { +if ($($build.editionid -like 'ServerDatacenter*') -or $($build.editionid -like 'ServerStandard*') -or $($build.editionid -like 'Professional*') -or $($build.editionid -like 'Enterprise*') -or $($build.editionid -like 'Education*')) { Return $true } Else { - Write-Warning "Only Windows 10 20H1 or Windows 11 (Pro or Enterprise) is supported" + Write-Warning "Only Windows 10 20H1, Windows 11 (Pro or Enterprise) and Windows Server is supported" Return $false } } @@ -30,7 +30,7 @@ if (Get-WindowsOptionalFeature -Online | Where-Object FeatureName -Like 'Microso Return $true } Else { - Write-Warning "You need to enable Virtualisation in your motherboard and then add the Hyper-V Windows Feature and reboot" + Write-Warning "You need to enable Virtualisation in your motherboard and then add the Hyper-V Windows Feature and reboot`nYou can run the following command:`nEnable-WindowsOptionalFeature -Online -FeatureName `"Microsoft-Hyper-V-All`"" Return $false } } From 2cd48ac3355a821aeaf1712288e2ccb73c571b75 Mon Sep 17 00:00:00 2001 From: 841973620 <841973620@qq.com> Date: Mon, 3 Apr 2023 01:36:44 +0800 Subject: [PATCH 2/3] Update CopyFilesToVM.ps1 fixed a problem where other language image packages cannot be read, and modify to allow users to choose the listed Windows images themselves --- CopyFilesToVM.ps1 | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index b24df3a..83c9472 100644 --- a/CopyFilesToVM.ps1 +++ b/CopyFilesToVM.ps1 @@ -1999,38 +1999,8 @@ You can use the fields below to configure the VHD or VHDX that you want to creat #################################################################################################### Write-W2VInfo "Looking for the requested Windows image in the WIM file" - $WindowsImage = Get-WindowsImage -ImagePath "$($driveLetter):\sources\install.wim" - - if (-not $WindowsImage -or ($WindowsImage -is [System.Array])) - { - # - # WIM may have multiple images. Filter on Edition (can be index or name) and try to find a unique image - # - $EditionIndex = 0; - if ([Int32]::TryParse($Edition, [ref]$EditionIndex)) - { - $WindowsImage = Get-WindowsImage -ImagePath $SourcePath -Index $EditionIndex - } - else - { - $WindowsImage = Get-WindowsImage -ImagePath $SourcePath | Where-Object {$_.ImageName -ilike "*$($Edition)"} - } - - if (-not $WindowsImage) - { - throw "Requested windows Image was not found on the WIM file!" - } - if ($WindowsImage -is [System.Array]) - { - Write-W2VInfo "WIM file has the following $($WindowsImage.Count) images that match filter *$($Edition)" - Get-WindowsImage -ImagePath $SourcePath - - Write-W2VError "You must specify an Edition or SKU index, since the WIM has more than one image." - throw "There are more than one images that match ImageName filter *$($Edition)" - } - } - - $ImageIndex = $WindowsImage[0].ImageIndex + $WindowsImage = Get-WindowsImage -ImagePath "$($driveLetter):\sources\install.wim" | Format-Table | Out-Host -Paging + $ImageIndex = Read-Host "Please enter ImageIndex" # We're good. Open the WIM container. # NOTE: this is only required because we want to get the XML-based meta-data at the end. Is there a better way? @@ -4404,4 +4374,3 @@ In a few minutes it will load the Windows desktop, when it does, sign into Parsec (a fast remote desktop app) and connect to the machine using Parsec from another computer. Have fun! -Sign up to Parsec at https://parsec.app" From 0eb51a9fe453fa623005cc0daf6b027b55ca5e85 Mon Sep 17 00:00:00 2001 From: 841973620 <841973620@qq.com> Date: Mon, 3 Apr 2023 01:44:22 +0800 Subject: [PATCH 3/3] Update CopyFilesToVM.ps1 Add a registry key to mask Windows GPU Partition security checks (Error code: 0x800705AA) --- CopyFilesToVM.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index 83c9472..2b83d2c 100644 --- a/CopyFilesToVM.ps1 +++ b/CopyFilesToVM.ps1 @@ -4367,10 +4367,14 @@ Check-Params @params New-GPUEnabledVM @params +New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HyperV" +Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HyperV" -Name "RequireSecureDeviceAssignment" -Type DWORD -Value 0 -Force +Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HyperV" -Name "RequireSupportedDeviceAssignment" -Type DWORD -Value 0 -Force + Start-VM -Name $params.VMName SmartExit -ExitReason "If all went well the Virtual Machine will have started, In a few minutes it will load the Windows desktop, when it does, sign into Parsec (a fast remote desktop app) and connect to the machine using Parsec from another computer. -Have fun! +Have fun!"