Hi,
I'm trying to change the color of the values at the moment it does a yellow and blue and i would like red for disk used and green for disk free, but wondering what command i would need to input.
here is the code i have used some code i found on the internet in the meantime.
Function Create-PieChart() {
param([string]$FileName)
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
#Create our chart object
$Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart
$Chart.Width = 400
$Chart.Height = 320
$Chart.Left = 10
$Chart.Top = 10
#Create a chartarea to draw on and add this to the chart
$ChartArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
$Chart.ChartAreas.Add($ChartArea)
[void]$Chart.Series.Add("Data")
#Add a datapoint for each value specified in the arguments (args)
foreach ($value in $args[0]) {
Write-Host "Now processing chart value: " + $value
$datapoint = new-object System.Windows.Forms.DataVisualization.Charting.DataPoint(0, $value)
$datapoint.AxisLabel = "Value" + "(" + $value + " GB)"
$Chart.Series["Data"].Points.Add($datapoint)
}
$Chart.Series["Data"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::Pie
$Chart.Series["Data"]["PieLabelStyle"] = "Outside"
$Chart.Series["Data"]["PieLineColor"] = "Black"
$Chart.Series["Data"]["PieDrawingStyle"] = "Concave"
$Chart.Series["Data"]
($Chart.Series["Data"].Points.FindMaxByValue())["Exploded"] = $true
#Set the title of the Chart to the current date and time
$Title = new-object System.Windows.Forms.DataVisualization.Charting.Title
$Chart.Titles.Add($Title)
$Chart.Titles[0].Text = "Disk Usage Chart (Used/Free)"
#Save the chart to a file
$Chart.SaveImage($FileName + ".png","png")
}
# Disk Space Fucntions
$Disks = @(gwmi Win32_LogicalDisk -Filter "DriveType=3")
foreach($disk in $Disks)
{
$UsedDisk = [System.Math]::Round(($disk.Size - $disk.freespace)/1gb)
$FreeDisk = [System.Math]::Round($disk.freespace/1gb)
}
# Where the graph is going to get saved too
Create-PieChart -FileName ((Get-Location).Path + "\chart-$computer") $FreeDisk, $UsedDisk
$ListOfAttachments += "chart-$computer.png"