##PoshBoard Widget for Basic Performance of Physical (Hyper-V) Hardware ##v1.0 Function CpuChart { $Chart = New-PbChart -Name "CPU Monitor" -Title "CPU Monitor" -Theme Theme1 -Row 0 -Column 0 $LogicalCpuUsage = Get-Counter “\Hyper-V Hypervisor Logical Processor(_Total)\% Hypervisor Run Time” -Computer %ComputerName%|%{$_.CounterSamples[0].CookedValue} $GuestCpuUsage = Get-Counter “\Hyper-V Hypervisor Logical Processor(_Total)\% Guest Run Time” -Computer %ComputerName%|%{$_.CounterSamples[0].CookedValue} $a = New-PbChartSerie -Name "Total Hypervisor RunTime" -LegendText "Hypervisor Workload" -RenderAs StackedColumn100 -Color Red $a.AddDataPoint("CPU Usage",$LogicalCpuUsage) $b = New-PbChartSerie -Name "Total Guest RunTime" -LegendText "Guest(s) Workload" -RenderAs StackedColumn100 -Color Orange $b.AddDataPoint("CPU Usage",$GuestCpuUsage) $c = New-PbChartSerie -Name "Idle RunTime" -LegendText "Idle Workload" -RenderAs StackedColumn100 -Color Green $c.AddDataPoint("CPU Usage",100 - $LogicalCpuUsage - $GuestCpuUsage) Add-PbChartSeries $Chart $a,$b,$c $Chart } Function RamChart { $Chart = New-PbChart -Name "RAM Monitor" -Title "RAM Monitor" -Theme Theme1 -Row 0 -Column 1 $TotalMemory = (gwmi -Computer %ComputerName% -query("select TotalPhysicalMemory from Win32_ComputerSystem")).TotalPhysicalMemory/1024 $FreeRam = (gwmi -Computer %ComputerName% -Query("select FreePhysicalMemory from Win32_OperatingSystem")).FreePhysicalMemory $a = New-PbChartSerie -Name "Used RAM" -LegendText "Used RAM" -RenderAs StackedColumn -Color Red $a.AddDataPoint("RAM Usage",$TotalMemory-$FreeRam) $b = New-PbChartSerie -Name "Free RAM" -LegendText "Free RAM" -RenderAs StackedColumn -Color Green $b.AddDataPoint("RAM Usage",$FreeRam) Add-PbChartSeries $Chart $a,$b $Chart } Function DiskPerformanceChart { $Chart = New-PbChart -Name "Disk I/O" -Title "Disk I/O Monitor" -Theme Theme1 -Animation $true -AddMode -Row 1 -ColumnSpan 2 $Time = Get-Date -uformat "%H:%M:%S" $ReadTimeCounter = Get-Counter -ComputerName %ComputerName% -Counter "\PhysicalDisk(_Total)\% Disk Read Time" $WriteTimeCounter = Get-Counter -ComputerName %ComputerName% -Counter "\PhysicalDisk(_Total)\% Disk Write Time" $ReadTime = $ReadTimeCounter.CounterSamples[0].CookedValue $WriteTime = $WriteTimeCounter.CounterSamples[0].CookedValue $a = New-PbChartSerie -Name "a" -LegendText "Percent ReadTime" -RenderAs Line -Color Blue $a.AddDataPoint($Time,$ReadTime) $b = New-PbChartSerie -name "b" -LegendText "Percent WriteTime" -RenderAs Line -Color Green $b.AddDataPoint($Time,$WriteTime) Start-Sleep -Milliseconds 50 Add-PbChartSeries $Chart $a,$b $Chart } Function DiskUsageChart($Type,$Capacity,$FreeSpace,$ChartName) { $Chart = New-PbChart -Name $ChartName -Theme "Theme1" -Title "Disk Usage Monitor" $a = New-PbChartSerie -Name "FreeSpace" -RenderAs $Type $a.AddColoredDataPoint("Free Gb",$FreeSpace,"Blue") $b = New-PbChartSerie -Name "Used" -LegendText "Capacity" -RenderAs $Type $a.AddColoredDataPoint("Used Gb",$Capacity-$FreeSpace,"Green") Start-Sleep -Milliseconds 50 Add-PbChartSeries $Chart $a $Chart } Function DiskUsageChartTabs($Volumes,$Tabs,$Capacity,$FreeSpace,$ChartName) { $Tabs = New-PbTab -Name "Disk Usage" -FontSize 10 -Row 2 -ColumnSpan 2 $Volumes = gwmi -Computer %ComputerName% -q "select Name, Label, Capacity, FreeSpace from Win32_Volume where drivetype !='5'" $Volumes|%{ $ChartName = $_.Name $Label = $_.Label $Capacity = [math]::round($_.Capacity/1024/1024/1024,2) $FreeSpace = [math]::round($_.FreeSpace/1024/1024/1024,2) Add-PbItem $Tabs (DiskUsageChart "Pie" "$Capacity" "$FreeSpace" "$ChartName ($Capacity Gb)") } $Tabs } $Grid = New-PbGrid -Rows ("1*","1*","1*") -Columns ("1*","1*") Add-PbItem $Grid (CpuChart) Add-PbItem $Grid (RamChart) Add-PbItem $Grid (DiskPerformanceChart) Add-PbItem $Grid (DiskUsageChartTabs) $Grid