# Getting an \* in HTML output

**URL:** <https://forums.powershell.org/t/getting-an-in-html-output/2976>\
**Category:** PowerShell Help\
**Created:** [August 17, 2014, 3:05am UTC](https://forums.powershell.org/t/getting-an-in-html-output/2976 "2014-08-17T03:05:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![terry-mckenna](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@terry-mckenna](https://forums.powershell.org/u/terry-mckenna)\
**Post date:** [August 17, 2014, 3:05am UTC](https://forums.powershell.org/t/getting-an-in-html-output/2976/1 "2014-08-17T03:05:56Z")

</div>

Hi Guys,

I am trying to generate an HTML report and have come across an issue where if my hashtable has a single key-value pair the output displays an \* on the html but if I have 2 or more key-value pairs it’s not an issue. Something to do with what the function returns??

```
# This script will create an html file in your current location named $computername.html
$Path = Get-Location
$ComputerName = $env:COMPUTERNAME

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

function Get-InfoOS2 {
    $os = Get-WmiObject -class Win32_OperatingSystem -ComputerName $ComputerName
    $props = @{'OSVersion'=$os.version;
               'SPVersion'=$os.servicepackmajorversion;
               'Edition'=$os.caption}
    New-Object -TypeName PSObject -Property $props
}

$filepath = Join-Path -Path $Path -ChildPath "$computerName.html"
$html_os = Get-InfoOS -ComputerName $computerName |
           ConvertTo-HTML -As List -Fragment -PreContent "OS" |
           Out-String
           
$html_os2 = Get-InfoOS2 -ComputerName $computerName |
           ConvertTo-HTML -As List -Fragment -PreContent "OS 2" |
           Out-String
           
$params = @{'Title'="Report for $computer";
                    'PreContent'="System Report for $computerName";
                    'PostContent'=$html_os,$html_os2}
        ConvertTo-HTML @params | Out-File -FilePath $filepath
```

The output looks like this:

```
OS

*:	Microsoft Windows 7 Enterprise

OS 2

OSVersion:	6.1.7601
Edition:	Microsoft Windows 7 Enterprise
SPVersion:	1
```

Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![simon-wahlin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/simon-wahlin/32/407_2.png) [@simon-wahlin](https://forums.powershell.org/u/simon-wahlin)\
**Post date:** [August 17, 2014, 6:01am UTC](https://forums.powershell.org/t/getting-an-in-html-output/2976/2 "2014-08-17T06:01:57Z")

</div>

Hi Terry,

I cannot explain this odd behavior of ConvertTo-HTML, but in my experience, explicitly specifying which properties that should be converted to HTML using the parameter -Property will solve the problem.

Example 1, showing the same problem as in your post:

```
$object1 = [PSCustomObject]@{
    One = '1'
}

$object2 = [PSCustomObject]@{
    One = '1'
    Two = '2'
}

$object1 | ConvertTo-HTML -Fragment -As List | Out-String
$object2 | ConvertTo-HTML -Fragment -As List | Out-String
```

The output is:

```
*:1

One:1
Two:2
```

Example 2:  
Now I’m using Get-Member -MemberType \*Property | Select-Object -ExpandProperty Name to get a list of all properties that I want to convert to HTML and specify these to the cmdlet ConvertTo-HTML:

```
$object1 = [PSCustomObject]@{
    One = '1'
}

$object2 = [PSCustomObject]@{
    One = '1'
    Two = '2'
}

$Properties1 = $object1 | 
    Get-Member -MemberType *Property | 
        Select-Object -ExpandProperty Name
$object1 | ConvertTo-HTML -Fragment -As List -Property $Properties1 | Out-String

$Properties2 = $object2 | 
    Get-Member -MemberType *Property | 
        Select-Object -ExpandProperty Name
$object2 | ConvertTo-HTML -Fragment -As List -Property $Properties2 | Out-String
```

Now I get the output:

```
One:1

One:1
Two:2
```

And ofcourse you dont need to use Get-Member, if you know which properties you want, just specify them.

---

<div class="post-metadata">

**Author:** ![terry-mckenna](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@terry-mckenna](https://forums.powershell.org/u/terry-mckenna)\
**Post date:** [August 18, 2014, 7:56am UTC](https://forums.powershell.org/t/getting-an-in-html-output/2976/3 "2014-08-18T07:56:15Z")

</div>

Thank you Simon, that resolved my issue.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:47pm UTC](https://forums.powershell.org/t/getting-an-in-html-output/2976/4 "2024-05-16T20:47:39Z")

</div>

Closed on May 16, 2024, 8:47pm UTC


