Author Posts

November 18, 2017 at 12:59 am

Hi I'm trying to test a function and pass it to the convertto-enhancedHTML and I get an error.

ConvertTo-EnhancedHTML : Parameter set cannot be resolved using the specified named parameters.
At line:25 char:14

here is the code

$filepath1 = "C:\Users\U611806\Desktop\MyFiles\PDFPowerShell\helderhtml.html"

$ComputerName = "localhost"

function Get-InfoOS {
$os = Get-WmiObject -class Win32_OperatingSystem -ComputerName $ComputerName
$props = @{'OSVersion'=$os.version
New-Object -TypeName PSObject -Property $props

$params = @{ 'As'='List';
$html_os = get-infoOS -ComputerName $ComputerName |ConvertTo-EnhancedHTMLFragment @params

$params2 = @{ 'Title'='System 1';
'Precontent'='H2>System 32 system';

ConvertTo-EnhancedHTML @params2 | Out-File -FilePath $filepath1

November 18, 2017 at 2:59 am

Try running your fragment through Out-String to start with. But the error usually means you haven't provided enough parameters for the binding to figure out which parameter set you want to use.

November 20, 2017 at 9:20 pm

same error. wonder is the syntas

$filepath = "C:\Users\U611806\Desktop\MyFiles\PDFPowerShell\html2.html"

$computer = "localhost"

function Get-InfoCompSystem {
$cs = Get-WmiObject -class Win32_ComputerSystem -ComputerName $ComputerName
$props = @{'Model'=$cs.model;
'RAM (GB)'="{0:N2}" -f ($cs.totalphysicalmemory / 1GB);
New-Object -TypeName PSObject -Property $props

$params = @{'As'='List';
'PreContent'='Computer System'}

$html_cs = Get-InfoCompSystem -ComputerName $computer |
ConvertTo-EnhancedHTMLFragment @params|Out-String

ConvertTo-EnhancedHTML -HTMLFragments $html_cs |Out-File $filepath