troubleshooting Question

Output to HTML in powershell

Avatar of Suresh Kumar
Suresh Kumar asked on
PowershellHTML
3 Comments1 Solution455 ViewsLast Modified:
[cmdletbinding()]
param
(
    [Parameter(Position=0,ValuefromPipeline=$true)]
    [string[]$ComputerName = $env:ComputerName
 
)
 
$vers=Invoke-Command -ComputerName $ComputerName  -ScriptBlock { opcagt -version }
$a = "<style>"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "</style>"
$vers| ConvertTo-html -Head $a -body "<H2>Version </H2>" | Out-file -Filepath C:\tmp\ver.txt
echo $ComputerName ,$vers
invoke-Expression c:\tmp\ver.txt
$vers | ConvertTo-html -Head $a -body "<H2>Version </H2>" | Out-file -Filepath C:\tmp\ver.txt
Get-Content 'C:\tmp\ver.txt' | Foreach-Object {$_ -replace '^<html.*$', ("<html>")}| Set-Content 'C:\tmp\ver1.txt'
cat C:\tmp\ver1.txt


This script works fine in the remote computer to find the OV version .but when tried to get the output in HTML..it gives me a different output like PSCcomputerName,RunspaceId,PSShow ComputerName,Length

Can some one help me on this
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 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 3 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