Closed sysxtreme closed 1 month ago
I ran it in verbose mode, and put some new Write-Verbose lines to find where the code is throwing error. I got this:
manage_etc_hosts: true
manage_resolv_conf: true
resolv_conf:
# cloudflare dns, src: https://1.1.1.1/dns/ nameservers: ['1.1.1.1', '1.0.0.1']
searchdomains:
- domain.local
domain: domain.local
power_state:
mode: reboot
message: Provisioning finished, will reboot ...
timeout: 15
VERBOSE:
Creating metadata iso for VM provisioning - VERBOSE: Filename: C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\ubuntu-1-metadata.iso
100% complete
VERBOSE: Metadata iso written
Done.
VERBOSE: Creating cache folder
VERBOSE: Get timestamp
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 response of content type text/plain of unknown size
New-HyperVCloudImageVM.ps1: You cannot call a method on a null-valued expression.
Also, I have changed this lines:
Set-Content "$($tempPath)\Bits\meta-data" ([byte[]][char[]] "$metadata") -Encoding Bytes
...
Set-Content "$($tempPath)\Bits\network-config" ([byte[]][char[]] "$networkconfig") -Encoding Bytes
...
Set-Content "$($tempPath)\Bits\user-data" ([byte[]][char[]] "$userdata") -Encoding Bytes
to this:
Set-Content "$($tempPath)\Bits\meta-data" ([byte[]][char[]] "$metadata") -Encoding "UTF-8"
...
Set-Content "$($tempPath)\Bits\network-config" ([byte[]][char[]] "$networkconfig") -Encoding "UTF-8"
...
Set-Content "$($tempPath)\Bits\user-data" ([byte[]][char[]] "$userdata") -Encoding "UTF-8"
It seems to be an issue related to the PowerShell version. I was using PowerShell 7.4.4 and got the error, but running the script on PowerShell version 5.1, system's default, it works fine.
I will add a check for the powershell version if my other pull request gets accepted. This would at least give a better error message.
1
Command:
Output:
2
So I tried to change the Byte enconding to UTF-8 and got new error:
Command:
Output:
I've tried different SO versions, same error.