Posted by: Preetam | March 20, 2008

PS C:\> Get-Service | ConvertTo-Html Name,Status | foreach{ >> if($_ -like "*<TD>Running</TD>*"){$_ -replace "<tr>","<tr bgcolor=green>"} >> else{$_ -replace "<TR>","<TR bgcolor=red>"}} | out-file servicescolors.htm


Responses

  1. Hi i get an error when i run this:
    The term ‘>>’ is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
    At :line:1 char:55
    + Get-Service | ConvertTo-Html Name,Status | foreach{ >> <<<< if($_ -like “*Running*”){$_ -replace “”,””} >> else{$_ -replace “”,””}} | out-file c:\scripts\servicescolors.htm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: