Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Keys Values
  2. chrome 10
  3. explorer 5
  4. firefox 7
  5.  
  6. $GetCon = Get-NetTCPConnection
  7.  
  8.  
  9. $GName = foreach ($process in $GetCon) {
  10.  
  11. $processName = (Get-Process -Id $process.OwningProcess).ProcessName
  12. $process | Add-Member -NotePropertyName ProcessName -NotePropertyValue $processName -PassThru
  13. }
  14.  
  15. $gnmcnt = $GetCon | select -ExpandProperty ProcessName
  16. $frcnt=@{}
  17. $gnmcnt | % {if (!($frcnt.ContainsKey($_))) {$frcnt.Add($_,1)} else {$frcnt.Item($_)=$frcnt.Item($_) +1}}
  18.  
  19.  
  20.  
  21.  
  22. $TableBody,$StrBody=""
  23.  
  24.  
  25. $frcnt | ForEach-Object {
  26.  
  27. $TableBody+="<tr><td>$($_.Keys)</td> <td>$($_.Values)</td></tr>"
  28.  
  29. }
  30.  
  31.  
  32. $Body =@"
  33. <table>
  34. <th>Process</th><th>Count</th>
  35. $TableBody
  36. </table>
  37. "@
  38.  
  39. $Head = "<Style> body {Background-color: lightblue; } table {background-color: white; margin: 5px; float: left; top: 0px; display: inline-block; padding:5px; border: 1px solid black} tr:nth-child(odd) {background-color: lightgray} </style>"
  40.  
  41.  
  42. $HTML = ConvertTo-Html -Body $Body -Head $Head
  43.  
  44.  
  45. $HTML | Out-File -filepath "C:temptest.html" -Force
  46.  
  47. Invoke-Item "C:temptest.html"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement