x0nn / Convert-WindowsImage

Creates a Windows VM for Hyper-V from a Windows-ISO
GNU General Public License v3.0
80 stars 21 forks source link

Cannot find BootManager? #16

Closed suntong closed 3 years ago

suntong commented 3 years ago

Getting the following error:

Write-LogMessage : 2021-05-29T21:06:57 [myhn] Error formatting a string: Input string was not in a correct format..
At D:\...\WindowsPowerShell\Convert-WindowsImage.ps1:2314 char:13
+             Write-LogMessage $_ -logType Error
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-LogMessage

Tried twice, and the error is exactly the same. Apparently it comes from:

https://github.com/x0nn/Convert-WindowsImage/blob/21f2abb8abce04d820c3e384de553e266bfc9b0d/Convert-WindowsImage.ps1#L2312-L2316

Here is the full log:

**********************
Windows PowerShell transcript start
Start time: 20210529172616
Username: me
RunAs User: me
Configuration Name: 
Machine: myhn (Microsoft Windows NT 10.0.19041.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 26584
PSVersion: 5.1.19041.610
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.610
BuildVersion: 10.0.19041.610
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
PS>TerminatingError(Write-LogMessage): "Error formatting a string: Input string was not in a correct format.."
>> TerminatingError(Write-LogMessage): "Error formatting a string: Input string was not in a correct format.."
Write-LogMessage : 2021-05-29T21:29:02 [myhn] Error formatting a string: Input string was not in a correct 
format..
At D:\...\WindowsPowerShell\Convert-WindowsImage.ps1:2314 char:13
+             Write-LogMessage $_ -logType Error
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-LogMessage
Write-LogMessage : 2021-05-29T21:29:02 [myhn] Error formatting a string: Input string was not in a correct
format..
At D:\...\WindowsPowerShell\Convert-WindowsImage.ps1:2314 char:13
+             Write-LogMessage $_ -logType Error
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-LogMessage

**********************
Windows PowerShell transcript end
End time: 20210529172904
**********************

Other logs look good except the file bcdboot.exe-StandardOutput.txt:

BFSVC: ServiceBootFiles MuiOnly:n Res:y Fonts:y BootMgrOvw:n BootStatOvw:n DbgTrn:y SuspendBDE:n
BFSVC: Using source OS version a00004a610001
BFSVC: Copying boot files CopyBootManager(Yes) F:\Windows\boot\PCAT -> \\?\GLOBALROOT\Device\HarddiskVolume9\Boot 
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\bg-BG\bootmgr.exe.mui for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\bootmgr for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\bootuwf.dll for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\bootvhd.dll for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\cs-CZ\bootmgr.exe.mui for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\cs-CZ\memtest.exe.mui for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
BFSVC: Unable to open file \\?\GLOBALROOT\Device\HarddiskVolume9\Boot\da-DK\bootmgr.exe.mui for read because the file or path does not exist
BFSVC: SetNamedSecurityInfo failed! Error code = 0x2
. . .
x0nn commented 3 years ago

Hi,

thanks for your feedback. Please append the parameters you used.

suntong commented 3 years ago

Convert-WindowsImage -DiskLayout BIOS -VHDFormat VHD -BCDinVHD VirtualMachine -ExpandOnNativeBoot:$false -Edition "Windows 10 Pro N" -SizeBytes 30GB -SourcePath E:\sources\install.esd -VHDPath ...

and I just ran without the -BCDinVHD VirtualMachine part, and confirm that the problem is still the same.

craiglandis commented 3 years ago

I'm blocked on the same error:

From Win10 21H1 PS5.1, repros the same with or without my profile loading (powershell -noprofile).

Looking at the code I'm wondering if it's something to do with the braces in bcdedit args around line 2082.

PS C:\> Convert-WindowsImage -SourcePath c:\iso\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso -Edition 'Windows Server 2016 Datacenter (Desktop Experience)' -DiskLayout BIOS -VHDPath D:\vhds\test.vhd -Verbose

Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 10                                                                                                                                                                    Copyright (C) Microsoft Corporation.  All rights reserved.                                                                                                                                                                           Version 10.0.14278.1000.amd64fre.rs1_es_media.160201-1707                                                                                                                                                                                                                                                                                                                                                                                                                 VERBOSE: Target Image Version 10.0.19043.1052                                                                                                                                                                                        VERBOSE: 2021-07-08T03:12:02 [TEN] Temporary VHD path is : D:\vhds\22409e74-daa9-4dac-9aed-724521bd3aba.vhd                                                                                                                          VERBOSE: 2021-07-08T03:12:02 [TEN] Opening ISO en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Attached          : True
BlockSize         : 0
DevicePath        : \\.\CDROM0
FileSize          : 6006587392
ImagePath         : C:\iso\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso
LogicalSectorSize : 2048
Number            : 0
Size              : 6006587392
StorageType       : 1
PSComputerName    :

VERBOSE: 2021-07-08T03:12:03 [TEN] Looking for c:\iso\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso...
VERBOSE: 2021-07-08T03:12:03 [TEN] Looking for the requested Windows image in the WIM file
VERBOSE: 2021-07-08T03:12:04 [TEN] Image 4 selected (Windows Server 2016 Datacenter (Desktop Experience))...
VERBOSE: 2021-07-08T03:12:04 [TEN] Creating sparse disk...
VERBOSE: 2021-07-08T03:12:06 [TEN] Mounting VHD...
VERBOSE: 2021-07-08T03:12:06 [TEN] Initializing disk...
VERBOSE: 2021-07-08T03:12:06 [TEN] Creating single partition...
VERBOSE: 2021-07-08T03:12:06 [TEN] Formatting windows volume...
VERBOSE: 2021-07-08T03:12:09 [TEN] Windows path (G:) has been assigned.
VERBOSE: 2021-07-08T03:12:09 [TEN] Windows path (G:) took 1 attempts to be assigned.
VERBOSE: 2021-07-08T03:12:09 [TEN] System volume location: G:
VERBOSE: 2021-07-08T03:12:09 [TEN] Applying image to VHD. This could take a while...
VERBOSE: 2021-07-08T03:15:35 [TEN] Image was applied successfully.
VERBOSE: 2021-07-08T03:15:35 [TEN] Making image bootable...
VERBOSE: 2021-07-08T03:15:38 [TEN] Fixing the Device ID in the BCD store on VHD...
Write-LogMessage : 2021-07-08T03:15:38 [TEN] Error formatting a string: Input string was not in a correct format..
At C:\OneDrive\My\Convert-WindowsImage.ps1:2313 char:13
+             Write-LogMessage $_ -logType Error
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-LogMessage

VERBOSE: 2021-07-08T03:15:38 [TEN] Log folder is C:\Users\clandis\AppData\Local\Temp\Convert-WindowsImage\22409e74-daa9-4dac-9aed-724521bd3aba
VERBOSE: 2021-07-08T03:15:40 [TEN] Closing ISO...
Attached          : False
BlockSize         : 0
DevicePath        :
FileSize          : 6006587392
ImagePath         : C:\iso\en_windows_server_2016_updated_feb_2018_x64_dvd_11636692.iso
LogicalSectorSize : 2048
Number            :
Size              : 6006587392
StorageType       : 1
PSComputerName    :

VERBOSE: 2021-07-08T03:15:41 [TEN] Done.
x0nn commented 3 years ago

Hi,

thanks for your feedback and patience. I found the error and fixed it. I will merge the code today.

Best Regards