Product: PowerShell Universal
Version: 1.4.6
Good evening everyone,
I’m trying to create a charge of free disk space for each server in a specific OU. It creates a charter for each server but does not populate the charts with the bars. I have 11 servers in the OU, it creates 11 charts which is what I want, they’re just empty. Thanks
Code:
$serverList = (Get-ADComputer -Filter * -SearchBase "OU=Servers,OU=Computers,DC=local" | Select-Object -ExpandProperty Name)
foreach ($server in $serverList) {
$GraphPrep = @(
Disk = $server; TotalDiskSpace = ((Get-CimInstance -ComputerName $server -ClassName Win32_LogicalDisk -Filter "DeviceID='C:'").Size / 1GB | ForEach-Object { "$([Math]::Round($_, 2)) GBs " }); FreeDiskSpace = ((Get-CimInstance -ComputerName $server -ClassName Win32_LogicalDisk -Filter "DeviceID='C:'").FreeSpace / 1GB | ForEach-Object { "$([Math]::Round($_, 2)) GBs " })
)
$availableDiskSpace = New-UDChartJSDataset -DataProperty "TotalDiskSpace" -Label 'Total' -BackgroundColor blue
$freeDiskSpace = New-UDChartJSDataset -DataProperty "FreeDiskSpace" -Label 'Free' -BackgroundColor red
$Options = @{
Type = 'bar'
Data = $GraphPrep
Dataset = @($availableDiskSpace, $freeDiskSpace)
LabelProperty = "Disk"
Options = @{
scales = @{
xAxes = @(
@{
stacked = $true
}
)
yAxes = @(
@{
stacked = $true
}
)
}
}
}
New-UDChartJS @Options
}