troubleshooting Question

Ouput in html in powershell

Avatar of Suresh Kumar
Suresh Kumar asked on
PowershellHTML
2 Comments1 Solution134 ViewsLast Modified:
[cmdletbinding()]
param
(
    [Parameter(Position=0,ValuefromPipeline=$true)]
    [string[]$ComputerName = $env:ComputerName
)
 
$vers = Invoke-Command -ComputerName $ComputerName -ScriptBlock { New-Object PsObject -Property @{ Version = opctemplate} }
$a = @"
<style>
TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}
TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}
TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}
</style>
"@

$vers | ConvertTo-html -Head $a -body "<H2>Version </H2>" -Property Version | Out-file -Filepath C:\tmp\ver.html

When i run the above script i get the ouput  as


List of Policies

* List installed policies for host 'localhost'. Type Name Status Version -------------------------------------------------------------------- configsettings "OPC_COND_EVT_LOG_SRC_PAT" enabled 0001.0000 le "LAG_Administrator group Alert" enabled 0001.0028 le "Win2k-AppEventLog" enabled 0001.0036 le "Win2k-SecEventLog" enabled 0001.0005 le "Win2k-SysEventLog" enabled 0001.0027 monitor "BladeLogic Restart if over 30% CPU" enabled 0001.0004 monitor "Lanman_ServiceMon" enabled 0001.0004 monitor "Log Monitoring Service Restart if over 30% CPU" enabled 0001.0001 monitor "SEP_Monitoring" enabled 0001.0005 monitor "TripwireServiceMon" enabled 0001.0001 monitor "Win2k-VirtualMemoryUtilization" enabled 0001.0009 msgi "Win2k-opcmsg" enabled 0001.0051 sched "Win2k-DiskSpace-Friday0000AM-1600PM" enabled 0001.0001 sched "Win2k-DiskSpace-Monday-Thursday" enabled 0001.0001 sched "Win2k-DiskSpace-Sunday0800AM_2359PM" enabled 0001.0001 sched "Win2k-DiskSpaceConf" enabled 0001.0007  

But I need the output in the below format



 Type              Name                        Status     Version
--------------------------------------------------------------------
 configsettings    "OPC_COND_EVT_LOG_SRC_PAT"   enabled    0001.0000
 le                "LAG_Administrator group Alert"   enabled    0001.0028
 le                "Win2k-AppEventLog"         enabled    0001.0036
 le                "Win2k-SecEventLog"         enabled    0001.0005
 le                "Win2k-SysEventLog"         enabled    0001.0027
 monitor           "BladeLogic Restart if over 30% CPU"   enabled    0001.0004
 monitor           "Lanman_ServiceMon"         enabled    0001.0004
 monitor           "Log Monitoring Service Restart if over 30% CPU"   enabled
 0001.0001
 monitor           "SEP_Monitoring"            enabled    0001.0005
 monitor           "TripwireServiceMon"        enabled    0001.0001
 monitor           "Win2k-VirtualMemoryUtilization"   enabled    0001.0009
 msgi              "Win2k-opcmsg"              enabled    0001.0051
 sched             "Win2k-DiskSpace-Friday0000AM-1600PM"   enabled    0001.0001

 sched             "Win2k-DiskSpace-Monday-Thursday"   enabled    0001.0001
 sched             "Win2k-DiskSpace-Sunday0800AM_2359PM"   enabled    0001.0001

 sched             "Win2k-DiskSpaceConf"       enabled    0001.0007

can you help me on this
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros