diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index b24df3a..2b83d2c 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? @@ -4397,11 +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! -Sign up to Parsec at https://parsec.app" +Have fun!" 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 } }