Charts and PowerShell !! PowerShell Wrapper “Light Edition”

Check Out the Light Edition of this PowerShell Wrapper : Get-CorpCharts-FullEdition

I think one of the most interesting things when writing PowerShell scripts, is to make the results appear in a nice chart or couple of them. If you are going to show disk space info, nothing more than a nice chart will worth looking at. If you are sending a report to your management, nothing will take their attention more than charts. I love getting charts as  a high level output, with more tables and data for extra details.

Why this is different than others?

Because this script is a wrapper around the dirty stuff that you do not want to worry about, or may be you are new to PowerShell and  just what the chart to get generated.

You can just give it some data, and charts will start decorating your screen , ready to be emailed maybe to someone else to look at the data in a nice way.

The script

The script is FULL with examples and information of how to use it. Do not panic if you find the code long or complex for you. Just look at the examples and you will find your way.

Do not forget that you need to install two things before running the script on your machine :

So how the script works?

You have to enter a parameter called (-data) that is essentially an array of objects.

Suppose you have an object called (City) with two properties : City_Name, and City_Population

and let us say you have ten of those objects and they are stored in an array called $Cities

So now, all what you have to do is to give the $Cities array to the function as -Data parameter, and supply the -Obj_Key parameter as “City_Name”, and -Obj_Value as “City_Population”

So the command will be : Get-CorpCharts-LightEdition -data $Cities  -Obj_Key  City_Name  -Obj_Value City_Population -FilePath C:\graph.png


Download version 2

You can download version 2 of the script from here: Get-CorpCharts

New in Version 2

  • Sortable data option via -sort parameter.
  • Fix label alignment via -fix_label_alignment parameter.
  • Exposing X and Y axis intervals via parameters.
  • Show data as percentage via -show_percentage_pie parameter.
  • Collected threshold to group data items below the threshold into one item called ‘Others’.
  • Customizing chart data column colors via -chart_color parameter.
  • Dynamic dimension depending on the number of items in the input data.

Charts with PowerShell 1

Charts with PowerShell 2

Charts with PowerShell 3

Charts with PowerShell 4Charts with PowerShell 5

Charts with PowerShell 6



Chart by supplying array of objects as input. We are interested in the Name and Population properties of the input objects. In this case, we should also use the -obj_key and -obj_value parameters to tell the function which properties to draw. Default chart type ‘column’ is used.

PS C:\> Get-Corpchart-LightEdition -data $array_of_city_objects  -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png”


Specifying chart type as pie chart type.

PS C:\> Get-Corpchart-LightEdition -data  $cities  -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png” -type Pie


Specifying chart type as pie chart type. legend is shown.

PS C:\> Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png” -type Pie -showlegend


Specifying chart type as SplineArea chart type.

PS C:\> Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png” -type SplineArea


Specifying chart type as bar chart type, and specifying the title for the chart and x/y axis.

PS C:\> Get-Corpchart-LightEdition -data $cities  -obj_key  “Name” -obj_value  “Population”

-filepath “c:\chart.png”  -type Bar  -title_text  “people per country”  -chartarea_Xtitle  “cities”

 -chartarea_Ytitle  “population”


Specifying chart type as column chart type. Applying the -showHighLow switch to highlight the max and min values with different colors.

PS C:\> Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png” -type Column -showHighLow


Chart with percentages shown on the pie/doughnut charts.

PS C:\> Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png” -type Doughnut -Show_percentage_pie


If the chart type is pie or doughnut, you can specify a threshold (percentage) that all data values below it, will be shown as one data item called (Others).

PS C:\> Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population”

 -filepath “c:\chart.png” -type Doughnut  -CollectedThreshold 16


Column chart with green columns.

PS C:\> Get-Corpchart-LightEdition -data $cities -obj_key “Name” -obj_value “Population”

-filepath “c:\chart.png” -chart_color Green