Answer the question
In order to leave comments, you need to log in
How to add data to html output using Powershell?
I wrote a script
#$path = Test-Path "\\$computers\c$\Program Files (x86)\Application\App\App.exe"
$computers = Get-Content D:\Разработка\Powershell\Powershell_TXT_FILE\copms.txt |Where {-not ($_.StartsWith('#'))} | foreach {
if (test-connection $_ -quiet -count 1)
{
New-Object psobject -Property @{
Server = $_
Status = "Online"
}
}
else
{
New-Object psobject -Property @{
Server = $_
Status = "Offline"
}
}
}
$computers = $computers | Select-Object -Property Server,Status,App,Printer | ConvertTo-HTML |
Foreach {
if ($_ -like "*<td>Online</td>*" )
{
$_ -replace "<tr>","<tr bgcolor=green>"
}
else {
$_ -replace "<tr>","<tr bgcolor=red>" }
} | out-file D:\Разработка\Powershell\Powershell_TXT_FILE\test2.html
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question