Add-Type -AssemblyName System.Windows.Forms.DataVisualization 
# Instanciation de l'objet 
$Chart = New-Object  
Windows.Forms.DataVisualization.Charting.Chart 
[void]$Chart.Titles.Add('Taille des 3 principaux dossiers C:\') 
 
$Chart.Width = 600 
$Chart.Height =500 
$Chart.Left = 40 
$Chart.Top = 30 
 
$CA = New-Object Windows.Forms.DataVisualization.Charting.ChartArea 
$CA.AxisX.Title = 'Dossier' 
$CA.AxisY.Title = 'Taille des dossiers (en Go)' 
$Chart.ChartAreas.Add($CA) 
 
$TabF = 'C:\Users', 'C:\Windows', 'C:\Program Files' |  
Foreach-Object { 
    [PscustomObject]@{ 
        Path = [string]$(Split-Path -Path $_ -Leaf) 
        Size = (Get-ChildItem -Path $_ -File -Recurse |  
             Measure-Object -Property Length -Sum).Sum / 1GB 
    } 
} | Sort-Object -Property Size -Descending 
 
[void]$Chart.Series.Add('Data') 
$Chart.Series['Data'].Points.DataBindXY($TabF.Path,$TabF.Size) 
$Chart.Series['Data'].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType] 
::Column 
 
$CHart.Series['Data']['DrawingStyle'] = 'Cylinder' 
 
$maxValuePoint = $Chart.Series['Data'].Points.FindMaxByValue() 
$maxValuePoint.Color = [System.Drawing.Color]::Red 
$minValuePoint = $Chart.Series['Data'].Points.FindMinByValue() 
$minValuePoint.Color = [System.Drawing.Color]::Green 
 
$Form = New-object Windows.Forms.Form 
$Form.Text = 'Taille des 3 principaux dossiers C:\' 
$Form.Width = 700 
$Form.Height = 600 
$Form.Controls.Add($Chart) 
 
$Form.Add_Shown( {$Form.Activate}) 
$Form.ShowDialog()
