Home > Software engineering >  ConvertTo-EnhancedHTML : Parameter set cannot be resolved using the specified named parameters
ConvertTo-EnhancedHTML : Parameter set cannot be resolved using the specified named parameters

Time:12-21

The code:

$Bios = Get-WmiObject -class Win32_BIOS | Select-Object -Property PSComputerName,Manufacturer,BIOSVersion | ConvertTo-EnhancedHTMLFragment -As List

$Bios2 = Get-WmiObject -class Win32_BIOS | Select-Object -Property PSComputerName,Manufacturer,BIOSVersion | ConvertTo-EnhancedHTMLFragment -As Table

ConvertTo-EnhancedHTML -HTMLFragments $Bios,$Bios2 | Out-File AsExample.html

The error:

ConvertTo-EnhancedHTML : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
  ConvertTo-EnhancedHTML -HTMLFragments $Bios,$Bios2 | Out-File AsExamp ...
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : InvalidArgument: (:) [ConvertTo-EnhancedHTML], ParameterBindingException
      FullyQualifiedErrorId : AmbiguousParameterSet,ConvertTo-EnhancedHTML

I don't understand why I am receiving the error. I've examined the help, and what I'm doing seems like it ought to be fair game:

-HTMLFragments <String[]>

    One or more HTML fragments, as produced by ConvertTo-EnhancedHTMLFragment.
    
    
        -HTMLFragments $part1,$part2,$part3

    Required?                    true
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

CodePudding user response:

I have resolved the error by specifying an additional parameter:

ConvertTo-EnhancedHTML -HTMLFragments $Bios,$Bios2 -CSSStyleSheet syles.css | Out-File AsExample.html

While reviewing the 2 available parameter sets for ConvertTo-EnhancedHTML, I noticed that there was only 1 parameter required in each one -- -HTMLFragments. The error was telling me it didn't know which parameter set I wanted to use. So what I ended up having to do was specify the -CSSStylesheet parameter, as that parameter and its opposing -CSSUri parameter are the only parameters unique to their respective sets. In other words, the command wouldn't execute because I had to specify one of the CSS parameters so powershell knew which parameter set to use DESPITE THE FACT THAT neither of the CSS parameters are actually required parameters. Wow!

  • Related