PowerShell HTML Output not displaying correctly -


i have powershell script outputting html. below snippet of code.

#services check write-host "services check" $html = $html + @"     <h3>services checks</h3>     <table>         <tr>             <th>name</th>             <th>result</th>         </tr> "@ get-service -computername server01 -name *service* |     foreach-object{     if($_.status -ne "running"){         write-host $_.name "is not running" -foregroundcolor "red"         $html = $html + @"         <tr>             <td class="name">$_.name</td>             <td class="red">is not running</td>         </tr> "@     }else{         write-host $_.name "is running" -foregroundcolor "green"         $html = $html + @"         <tr>             <td class="name">$_.name</td>             <td class="green">is running</td>         </tr> "@     } } $html = $html + "</table>" 

my issue on ps console output lists name of teh services fine in html output has result below (in table format).

services check system.serviceprocess.servicecontroller.name running

is there can pull in name oppose undescriptive listing.

thanks in advance

try write in $():

$($_.name) 

in string (double quotes) need force properties variable expansion in way.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -