I need a script that fetches the information and generates an HTML document. I'm looking for a way to make the columns of my report more friendly so I saw that it is possible to change them with [PSCustomObject] but after I go through this process the data. "System.Object[]" appears instead of the information. Can you help me?
$proc = Get-Process | select "ProcessName","ID"
$proc = foreach ($Procs in $proc) {
[PSCustomObject]@{
'Process Name' = $proc.processname
'identification' = $proc.id
}
}
$out = $proc | ConvertTo-Html -Property "Process Name","identification"
$out | Out-File -FilePath "c:\temp\file.html"
Try this, it works for me :)
$objects=@()
$processes = Get-Process | select "ProcessName","ID"
foreach ($proc in $processes) {
$objects+=[PSCustomObject]@{
'Process Name' = $proc.processname
'identification' = $proc.id
}
}
$out = $objects | ConvertTo-Html
$out | Out-File -FilePath "c:\temp\file.html"