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