We help IT Professionals succeed at work.
Get Started

Ouput in html in powershell

Suresh Kumar
Suresh Kumar asked
on
133 Views
Last Modified: 2017-03-17
[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
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE