Convert-WindowsImage icon indicating copy to clipboard operation
Convert-WindowsImage copied to clipboard

Directly use index if Edition fits exactly

Open bezik46 opened this issue 3 years ago • 6 comments

In command I have: -Edition "Windows Server 2022 SERVERSTANDARD"

Yet output shows:

Windows(R) Image to Virtual Hard Disk Converter for Windows(R)
Copyright (C) Microsoft Corporation.  All rights reserved.
Copyright (C) 2019 x0nn
Version 10.0.14278.1000.amd64fre.rs1_es_media.160201-1707

WARNING: 2022-01-22T08:16:22 [SP-P-MEDIA] The following images are in the image:
WARNING: 2022-01-22T08:16:22 [SP-P-MEDIA] Name: "Windows Server 2022 SERVERSTANDARDCORE" (Index: 1)
WARNING: 2022-01-22T08:16:22 [SP-P-MEDIA] Name: "Windows Server 2022 SERVERSTANDARD" (Index: 2)
Write-LogMessage : 2022-01-22T08:16:22 [SP-P-MEDIA] There is more than one WindowsImage (Edition) available. Choose
with -Edition using Name oder Index from the list above.
At C:\Convert-WindowsImage.ps1:2394 char:13
+             Write-LogMessage $_ -logType Error
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-LogMessage

bezik46 avatar Jan 22 '22 08:01 bezik46

Line 1848

Adjust, so it reads:

{$_.ImageName -ilike "*$($Edition)"}

Remove the second asterix * after Edition

bezik46 avatar Jan 22 '22 09:01 bezik46

I will add the code to check if the Edition-string fits exactly. You can use the index for now.

x0nn avatar Jan 26 '22 16:01 x0nn

I could not figure out what it accepted as Index (because the number or the name was not accepted)

bezik46 avatar Jan 29 '22 18:01 bezik46

Did you try:

-Edition 1 for example?

x0nn avatar Jan 31 '22 11:01 x0nn

Sure, could not find combination that got accepted

bezik46 avatar Feb 02 '22 08:02 bezik46

Can confirm that using -Edition [int] will in fact select the correct edition. I used it with -Edition 6, see the log below.

VERBOSE: 2022-06-08T08:03:20 [HOSTNAME] Looking for the requested Windows image in the WIM/ESD file...
VERBOSE: 2022-06-08T08:03:24 [HOSTNAME] Image 6 selected "Windows 11 Pro"
VERBOSE: 2022-06-08T08:03:24 [HOSTNAME] Creating sparse disk...

NielsS79 avatar Jun 08 '22 11:06 NielsS79