Suresh Kumar
asked on
Output to HTML in powershell
[cmdletbinding()]
param
(
[Parameter(Position=0,Valu efromPipel ine=$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
param
(
[Parameter(Position=0,Valu
[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
Can some one help me on this
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks ..it worked fine..
what in case if we want the Computer name in the output
I get the ouput like
version
11.14.014
I want something like
Verison
Computer Name
11.14.014
want the computername in the ouput
can you help me with this
what in case if we want the Computer name in the output
I get the ouput like
version
11.14.014
I want something like
Verison
Computer Name
11.14.014
want the computername in the ouput
can you help me with this
Open in new window