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 add type errors #15

Closed suntong closed 3 years ago

suntong commented 3 years ago
PowerShell 7.1.3

Convert-WindowsImage -DiskLayout BIOS -VHDFormat VHD -BCDinVHD VirtualMachine -ExpandOnNativeBoot:$false -Edition "Windows 10 Pro N" -SizeBytes 30GB -SourcePath D:\...\Sys\Windows10.iso -VHDPath L:\...\Win10\win10.vhd

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

Write-LogMessage: D:\...\WindowsPowerShell\Convert-WindowsImage.ps1:2314
Line |
2314 |              Write-LogMessage $_ -logType Error
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 2021-04-06T23:01:32 [...] Cannot add type. Compilation errors occurred.

This is the command that I used to use. However, when I tried today, I'm getting the above error.

What is the [xxx] Cannot add type errors and how can I fix it? thx

x0nn commented 3 years ago

Hi suntong,

thanks for committing your problem. Cause is that you use Powershell Core (pwsh). This is currently not supported. Please use Powershell 5.1. Since I do not use pwsh on windows I will not look into this. Please try it again and give feedback, if it worked for you.

Best Regards

suntong commented 3 years ago

Indeed, run with "Powershell 5.1 on a Windows System with administrator rights" will get over it.