Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed some issues #268

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 7 additions & 34 deletions CopyFilesToVM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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!"
6 changes: 3 additions & 3 deletions PreChecks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down