This is a simplified example using Get-Process
with a where clause. I have several HTML outputs I'm doing and I'd like to know if I can get the count of all objects limited by the where displayed in the HTML title called in the same line of code.
I don't want to do it in an additional line and was playing with Measure-Command
and $_.count
, but it was throwing away the data if I had it on the end of the pipe. Is anyone familiar with the syntax I should be using?
$processes = get-process | where { $_.name -like "s*"}
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$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;background-color:#CCCCCC}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:white}"
$a = $a + "</style>"
$processes | select * | convertto-HTML -head $a -body "<H2>Number of processes $_.count</H2>" | out-file c:\TEMP\COUNTTEST.htm
ii c:\TEMP\COUNTTEST.htm
I'd like the output to look like this(with the count of processes beginning with "S" in the title - 33 in this case):
----------------------------------
Number of processes 33
__NounName Name Handles VM WS
process SCNotification 295 243159040 8953856
Number of processes $($processes.Count)
"` ? – beatcracker Dec 01 '15 at 20:45