A
A
Artem Kiryanov2019-03-15 18:16:57
PowerShell
Artem Kiryanov, 2019-03-15 18:16:57

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

At the output, I get an html page, with the data filled in the first two columns. I want to add 1 more column check path status in folder on remote PCs. I don't know how to add functionality.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew AT, 2019-03-15
@hacker342

Change $path to "\\$_\c$\Program Files (x86)\Application\App\App.exe"
And add something like IsPath = Test-Path $path to $psobject
Good luck!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question