function Convert-Wim2VHD {
[CmdletBinding(SupportsShouldProcess = $true,
PositionalBinding = $false,
ConfirmImpact = 'Medium')]
Param
(
# Path to the new VHDX file (Must end in .vhdx)
[Parameter(Position = 0, Mandatory = $true,
HelpMessage = 'Enter the path for the new VHDX file')]
[ValidateNotNullorEmpty()]
[ValidatePattern(".\.vhdx?$")]
[ValidateScript( {
if (Get-FullFilePath -Path $_ |
Split-Path |
Resolve-Path ) {
$true
}
else {
Throw "Parent folder for $_ does not exist."
}
})]
[ValidateScript( {
if (Get-FullFilePath -Path $_ |
Split-Path |
Resolve-Path ) {
$true
}
else {
Throw “Parent folder for $_ does not exist.”
}
If I feed up this function with splatted input, I am getting error.
Is this a feature or a bug, and how to deal with it?
Of course I had formatted the hashtable properly: I have no clue where the distortion came from
What I can suppose… I have copied it from freshly installed VSCode and perhaps bad line endings come from it
Confirmed exception in the powershell console host.
Can it be bad encoding in git repo (cloned with freshly installed git clone)?
PS C:\dev> ipmo .\WindowsImageTools\WindowsImageTools\WindowsImageTools.psm1
WARNING: The names of some imported commands from the module ‘WindowsImageTools’ include unapproved verbs that might
make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the
Verbose parameter. For a list of approved verbs, type Get-Verb.
PS C:\dev> Convert-Wim2VHD -Path ‘H:\HyperVLab\Images\W2016_GUI.vhdx’ -Index 4 -Size 59GB -DiskLayout UEFI -Dynamic -Sou
rcePath ‘H:\HypervLab\Media\en_windows_server_2016_vl_x64_dvd_11636701.iso’ -WhatIf
What if: [Convert-Wim2VHD] : Overwrite partitions inside [H:\HyperVLab\Images\W2016_GUI.vhdx] with content of [H:\Hyperv
Lab\Media\en_windows_server_2016_vl_x64_dvd_11636701.iso]
PS C:\dev> $ConvertWim2VHD_Param = @{
>> Path = ‘H:\HyperVLab\Images\W2016_GUI.vhdx’
>> Index = 4
>> Size = 59GB
>> DiskLayout = ‘UEFI’
>> Dynamic = $true
>> SourcePath = ‘H:\HyperVLab\Media\en_windows_server_2016_vl_x64_dvd_11636701\Media\en_windows_server_2016_vl_x
64_dvd_11636701.iso’
>> }
PS C:\dev> Convert-Wim2VHD @$ConvertWim2VHD_Param -verbose
Convert-Wim2VHD : Cannot validate argument on parameter ‘Path’. Cannot bind argument to parameter ‘Path’ because it is
an empty string.
At line:1 char:17