![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Process Handle Count Charting Here using PowerShell with the .NET Microsoft Chart Controls (available for downloading now): # Define some variables. $processName = "svchost" $fileName = "$pwd\testData.csv" $chartName = "$pwd\myChart.gif" $selectOne = "PID" $selectTwo = "Handles" $output = $null [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization") $myChart = new-object System.Windows.Forms.DataVisualization.Charting.Chart $myChart.BackColor = "lightgreen" $myChart.Size = new-object System.Drawing.Size(560, 260) $myChartArea = new-object System.Windows.Forms.DataVisualization.Charting.ChartArea $myChartArea.BackColor = "CornSilk" $myChart.ChartAreas.Add($myChartArea) # Get some PowerShell data. $output = Get-Process | Where-Object { $_.Name -match "$processName" } | Select-Object @{Name="$selectOne"; Expression={ ($_.ID).ToString() }}, $selectTwo if ( $output -eq $null ) { " " "No $processName process(es) found!" " " Exit } # Output to a file (to demo doing any file data). $output | Export-Csv $fileName -noTypeInformation $fileData = Get-Content $fileName $titleFont = new-object System.Drawing.Font("Times New Roman", 24, [System.Drawing.FontStyle]::Bold) $title = new-object System.Windows.Forms.DataVisualization.Charting.Title $myChart.Titles.Add( $title ) $myChart.Titles[0].Text = "PowerShell Charting" $myChart.Titles[0].Font = $titleFont $myChart.Titles[0].ForeColor = "Brown" $mySeries1 = new-object System.Windows.Forms.DataVisualization.Charting.Series # The series X axis (Column) values. for($i=0;$i -lt ($fileData.count - 1);$i++) { [void]$mySeries1.Points.Add( $fileData[ ($i+1) ].Split(",")[1] ) } $myChart.Series.Add($mySeries1) # Series X axis label (column) names. for($i=0;$i -lt ($fileData.count - 1);$i++) { $myChart.Series["Series1"].Points[$i].AxisLabel = $fileData[ ($i+1) ].Split(",")[0] } # Find point (column) with maximum Y value and change color. $maxValuePoint = $myChart.Series["Series1"].Points.FindMaxByValue() $maxValuePoint.Color = [System.Drawing.Color]::FromArgb(255, 128, 128) $maxValuePoint.Label = "High " + $maxValuePoint.YValues $maxValuePoint.LabelForeColor = $maxValuePoint.Color # Find point (column) with minimum Y value and change color. $minValuePoint = $myChart.Series["Series1"].Points.FindMinByValue() $minValuePoint.Color = [System.Drawing.Color]::FromArgb(0, 0, 0) $minValuePoint.Label = "Low " + $minValuePoint.YValues $minValuePoint.LabelForeColor = $minValuePoint.Color # Adjust the above max and min fonts. $myChart.Series["Series1"].Font = new-object System.Drawing.Font("Arial", 14) # Axis (Y and X) titles. $myChartArea.AxisY.Title = "Handle Counts" $myChartArea.AxisY.TitleFont = new-object System.Drawing.Font("Times New Roman", 14, [System.Drawing.FontStyle]::Bold) $myChartArea.AxisX.Title = $processName + " processes by process ID numbers" $myChartArea.AxisX.TitleFont = $myChartArea.AxisY.TitleFont # Save the chart. $myChart.SaveImage("$chartName",[System.Windows.Forms.DataVisualization.Charting.ChartImageFormat]::Gif) Exit invoke-item myChart.gif Have fun charting! |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Easy to get handle from listbox. How to get listbox from handle? | .NET General | |||
| Process count wrong when only one process matches criteria | PowerShell | |||
| Local Session Manager Service - Excessive Handle Count? | Vista General | |||
| Local Session Manager Service - Excessive Handle Count? | Vista performance & maintenance | |||
| Windows Handle Count | Vista General | |||