diff --git a/CHANGELOG.md b/CHANGELOG.md index e024aa1..b3a9e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # :arrows_clockwise: Veeam VBR As Built Report Changelog -## [0.8.4] - 2024-01-0? +## [0.8.4] - 2024-01-16 ### Added @@ -17,8 +17,11 @@ ### Fixed -- Fix [#134](https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/issues/134) - Fix [#131](https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/issues/131) +- Fix [#132](https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/issues/132) +- Fix [#133](https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/issues/133) +- Fix [#134](https://github.com/AsBuiltReport/AsBuiltReport.Veeam.VBR/issues/134) + ## [0.8.3] - 2023-12-29 diff --git a/Src/Private/Get-AbrVbrAgentBackupjobConf.ps1 b/Src/Private/Get-AbrVbrAgentBackupjobConf.ps1 index 3793fce..f9b743f 100644 --- a/Src/Private/Get-AbrVbrAgentBackupjobConf.ps1 +++ b/Src/Private/Get-AbrVbrAgentBackupjobConf.ps1 @@ -738,6 +738,49 @@ function Get-AbrVbrAgentBackupjobConf { $TableParams['Caption'] = "- $($TableParams.Name)" } $OutObj | Table @TableParams + if ($ABkjob.ScheduleOptions.BackupTerminationWindowEnabled) { + try { + Section -Style NOTOCHeading6 -ExcludeFromTOC "Backup Window Time Period" { + Paragraph { + Text 'Permited \' -Color 81BC50 -Bold + Text ' Denied' -Color dddf62 -Bold + } + + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $ABkjob.ScheduleOptions.TerminationWindow + + $TableParams = @{ + Name = "Backup Window - $($ABkjob.Name)" + List = $true + ColumnWidths = 6,4,3,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,4,4,4,4,4,4 + Key = 'H' + } + if ($Report.ShowTableCaptions) { + $TableParams['Caption'] = "- $($TableParams.Name)" + } + if ($OutObj) { + $OutObj2 = Table -Hashtable $OutObj @TableParams + $OutObj2.Rows | Where-Object {$_.Sun -eq "0"} | Set-Style -Style OFF -Property "Sun" + $OutObj2.Rows | Where-Object {$_.Mon -eq "0"} | Set-Style -Style OFF -Property "Mon" + $OutObj2.Rows | Where-Object {$_.Tue -eq "0"} | Set-Style -Style OFF -Property "Tue" + $OutObj2.Rows | Where-Object {$_.Wed -eq "0"} | Set-Style -Style OFF -Property "Wed" + $OutObj2.Rows | Where-Object {$_.Thu -eq "0"} | Set-Style -Style OFF -Property "Thu" + $OutObj2.Rows | Where-Object {$_.Fri -eq "0"} | Set-Style -Style OFF -Property "Fri" + $OutObj2.Rows | Where-Object {$_.Sat -eq "0"} | Set-Style -Style OFF -Property "Sat" + + $OutObj2.Rows | Where-Object {$_.Sun -eq "1"} | Set-Style -Style ON -Property "Sun" + $OutObj2.Rows | Where-Object {$_.Mon -eq "1"} | Set-Style -Style ON -Property "Mon" + $OutObj2.Rows | Where-Object {$_.Tue -eq "1"} | Set-Style -Style ON -Property "Tue" + $OutObj2.Rows | Where-Object {$_.Wed -eq "1"} | Set-Style -Style ON -Property "Wed" + $OutObj2.Rows | Where-Object {$_.Thu -eq "1"} | Set-Style -Style ON -Property "Thu" + $OutObj2.Rows | Where-Object {$_.Fri -eq "1"} | Set-Style -Style ON -Property "Fri" + $OutObj2.Rows | Where-Object {$_.Sat -eq "1"} | Set-Style -Style ON -Property "Sat" + $OutObj2 + } + } + } catch { + Write-PscriboMessage -IsWarning $_.Exception.Message + } + } } catch { Write-PscriboMessage -IsWarning "Agent Backup Jobs Advanced Settings (Schedule Options) Section: $($_.Exception.Message)" diff --git a/Src/Private/Get-AbrVbrBackupCopyjobConf.ps1 b/Src/Private/Get-AbrVbrBackupCopyjobConf.ps1 index 996fc95..39aba10 100644 --- a/Src/Private/Get-AbrVbrBackupCopyjobConf.ps1 +++ b/Src/Private/Get-AbrVbrBackupCopyjobConf.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrBackupCopyjobConf { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.8.0 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -507,51 +507,8 @@ function Get-AbrVbrBackupCopyjobConf { Text 'Permited \' -Color 81BC50 -Bold Text ' Denied' -Color dddf62 -Bold } - $OutObj = @() - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } - - $ScheduleTimePeriod = $Bkjob.ScheduleOptions.TerminationWindow -split '(.{48})' | Where-Object {$_} - - foreach ($OBJ in $Hours24.GetEnumerator()) { - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $Bkjob.ScheduleOptions.TerminationWindow $TableParams = @{ Name = "Backup Window - $($Bkjob.Name)" diff --git a/Src/Private/Get-AbrVbrBackupProxy.ps1 b/Src/Private/Get-AbrVbrBackupProxy.ps1 index 144a933..d802788 100644 --- a/Src/Private/Get-AbrVbrBackupProxy.ps1 +++ b/Src/Private/Get-AbrVbrBackupProxy.ps1 @@ -447,11 +447,11 @@ function Get-AbrVbrBackupProxy { Write-PscriboMessage -IsWarning "VMware Backup Proxy Diagram: $($_.Exception.Message)" } if ($Graph) { - PageBreak Section -Style Heading3 "VMware Backup Proxy Diagram." { Image -Base64 $Graph -Text "VMware Backup Proxy Diagram" -Percent 20 -Align Center Paragraph "Image preview: Opens the image in a new tab to view it at full resolution." -Tabs 2 } + BlankLine } } } @@ -885,11 +885,11 @@ function Get-AbrVbrBackupProxy { Write-PscriboMessage -IsWarning "HyperV Backup Proxy Diagram: $($_.Exception.Message)" } if ($Graph) { - PageBreak Section -Style Heading3 "HyperV Backup Proxy Diagram." { Image -Base64 $Graph -Text "HyperV Backup Proxy Diagram" -Percent 20 -Align Center Paragraph "Image preview: Opens the image in a new tab to view it at full resolution." -Tabs 2 } + BlankLine } } } diff --git a/Src/Private/Get-AbrVbrBackupRepository.ps1 b/Src/Private/Get-AbrVbrBackupRepository.ps1 index 4721ffd..18b04fe 100644 --- a/Src/Private/Get-AbrVbrBackupRepository.ps1 +++ b/Src/Private/Get-AbrVbrBackupRepository.ps1 @@ -80,53 +80,18 @@ function Get-AbrVbrBackupRepository { try { $sampleData = $OutObj | Select-Object -Property 'Name','Used Space %' - $exampleChart = New-Chart -Name BackupRepository -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Name' - YField = 'Used Space %' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Backup Repository' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'UsedSpace' - Text = 'Percentage of Used Space' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning "Backup Repository graph Section: $($_.Exception.Message)" + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'BackupRepository' -XField 'Name' -YField 'Used Space %' -ChartLegendName 'Backup Repository' -ChartTitleName 'UsedSpace' -ChartTitleText 'Percentage of Used Space' + } catch { + Write-PscriboMessage -IsWarning "Backup Repository chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style Heading3 'Backup Repository' { Paragraph "The following section provides Backup Repository summary information." BlankLine if ($Options.EnableCharts -and $chartFileItem) { - Image -Text 'Backup Repository - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Backup Repository - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Sort-Object -Property 'Name' | Table @TableParams diff --git a/Src/Private/Get-AbrVbrBackupjob.ps1 b/Src/Private/Get-AbrVbrBackupjob.ps1 index 1efcd00..83e83ab 100644 --- a/Src/Private/Get-AbrVbrBackupjob.ps1 +++ b/Src/Private/Get-AbrVbrBackupjob.ps1 @@ -79,51 +79,15 @@ function Get-AbrVbrBackupjob { $Alljobs += (Get-VBRSureBackupJob -ErrorAction SilentlyContinue).LastResult } $sampleData = $Alljobs | Group-Object - $exampleChart = New-Chart -Name BackupJobs -Width 600 -Height 400 - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'BackupJobs' - AxisXTitle = 'Status' - AxisYTitle = 'Count' - NoAxisXMajorGridLines = $true - NoAxisYMajorGridLines = $true - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Name' - YField = 'Count' - Palette = 'Green' - ColorPerDataPoint = $true - } - $sampleData | Add-ColumnChartSeries @addChartSeriesParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'BackupJob' - Text = 'Jobs Latest Result' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru + $chartFileItem = Get-ColumnChart -SampleData $sampleData -ChartName 'BackupJobs' -XField 'Name' -YField 'Count' -ChartAreaName 'Infrastructure' -AxisXTitle 'Status' -AxisYTitle 'Count' -ChartTitleName 'BackupJobs' -ChartTitleText 'Jobs Latest Result' - if ($PassThru) - { - Write-Output -InputObject $chartFileItem - } - } - catch { - Write-PscriboMessage -IsWarning "$($_.Exception.Message) (Account Security Assessment Table)" + } catch { + Write-PscriboMessage -IsWarning "Backup Jobs chart section: $($_.Exception.Message)" } if ($OutObj) { if ($chartFileItem) { - Image -Text 'Backup Repository - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Backup Repository - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } Section -Style Heading3 'Backup Jobs' { Paragraph "The following section list backup jobs created in Veeam Backup & Replication." diff --git a/Src/Private/Get-AbrVbrBackupjobHyperV.ps1 b/Src/Private/Get-AbrVbrBackupjobHyperV.ps1 index 2771ee2..09c8a41 100644 --- a/Src/Private/Get-AbrVbrBackupjobHyperV.ps1 +++ b/Src/Private/Get-AbrVbrBackupjobHyperV.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrBackupjobHyperV { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.8.0 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -787,36 +787,11 @@ function Get-AbrVbrBackupjobHyperV { Text 'Permited \' -Color 81BC50 -Bold Text ' Denied' -Color dddf62 -Bold } - $OutObj = @() + try { - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } + $ScheduleTimePeriod = @() + $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' foreach ($Day in $Days) { $Regex = [Regex]::new("(?<=<$Day>)(.*)(?=)") @@ -826,31 +801,11 @@ function Get-AbrVbrBackupjobHyperV { $Match = $Regex.Match($BackupWindow) if($Match.Success) { - $ScheduleTimePeriodConverted = @() - - # foreach ($Val in $Match.Value.Split(',')) { - # if ($Val -eq 0) { - # $ScheduleTimePeriodConverted += 'on' - # } else {$ScheduleTimePeriodConverted += 'off'} - # } $ScheduleTimePeriod += $Match.Value } } - foreach ($OBJ in $Hours24.GetEnumerator()) { - - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $ScheduleTimePeriod $TableParams = @{ Name = "Backup Window - $($Bkjob.Name)" diff --git a/Src/Private/Get-AbrVbrBackupjobVMware.ps1 b/Src/Private/Get-AbrVbrBackupjobVMware.ps1 index 3e583c5..5388b62 100644 --- a/Src/Private/Get-AbrVbrBackupjobVMware.ps1 +++ b/Src/Private/Get-AbrVbrBackupjobVMware.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrBackupjobVMware { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.8.0 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -833,39 +833,13 @@ function Get-AbrVbrBackupjobVMware { Text 'Permited \' -Color 81BC50 -Bold Text ' Denied' -Color dddf62 -Bold } - $OutObj = @() - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } + $ScheduleTimePeriod = @() + $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' foreach ($Day in $Days) { $Regex = [Regex]::new("(?<=<$Day>)(.*)(?=)") - if ($Bkjob.TypeToString -eq "VMware Backup Copy" -or $Bkjob.TypeToString -eq "Backup Copy") { + if ($Bkjob.TypeToString -eq "VMware Backup Copy") { $BackupWindow = $Bkjob.ScheduleOptions.OptionsContinuous.Schedule } else {$BackupWindow = $Bkjob.ScheduleOptions.OptionsBackupWindow.BackupWindow} $Match = $Regex.Match($BackupWindow) @@ -875,20 +849,7 @@ function Get-AbrVbrBackupjobVMware { } } - foreach ($OBJ in $Hours24.GetEnumerator()) { - - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $ScheduleTimePeriod $TableParams = @{ Name = "Backup Window - $($Bkjob.Name)" diff --git a/Src/Private/Get-AbrVbrCloudConnectSummary.ps1 b/Src/Private/Get-AbrVbrCloudConnectSummary.ps1 index 88ff9e6..eac878b 100644 --- a/Src/Private/Get-AbrVbrCloudConnectSummary.ps1 +++ b/Src/Private/Get-AbrVbrCloudConnectSummary.ps1 @@ -5,7 +5,7 @@ function Get-AbrVbrCloudConnectSummary { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.7.1 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -60,51 +60,16 @@ function Get-AbrVbrCloudConnectSummary { try { $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name TapeInfrastructure -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Infrastructure' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'CloudConnectInventory' -XField 'Category' -YField 'Value' -ChartLegendName 'Infrastructure' + } catch { + Write-PscriboMessage -IsWarning "Cloud Connect Inventory chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Cloud Connect Infrastructure' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Cloud Connect Infrastructure - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Cloud Connect Infrastructure - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams diff --git a/Src/Private/Get-AbrVbrFileShareBackupjobConf.ps1 b/Src/Private/Get-AbrVbrFileShareBackupjobConf.ps1 index d3c218f..c790347 100644 --- a/Src/Private/Get-AbrVbrFileShareBackupjobConf.ps1 +++ b/Src/Private/Get-AbrVbrFileShareBackupjobConf.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrFileShareBackupjobConf { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.8.3 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -572,36 +572,11 @@ function Get-AbrVbrFileShareBackupjobConf { Text 'Permited \' -Color 81BC50 -Bold Text ' Denied' -Color dddf62 -Bold } - $OutObj = @() + try { - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } + $ScheduleTimePeriod = @() + $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' foreach ($Day in $Days) { $Regex = [Regex]::new("(?<=<$Day>)(.*)(?=)") @@ -611,31 +586,11 @@ function Get-AbrVbrFileShareBackupjobConf { $Match = $Regex.Match($BackupWindow) if($Match.Success) { - $ScheduleTimePeriodConverted = @() - - # foreach ($Val in $Match.Value.Split(',')) { - # if ($Val -eq 0) { - # $ScheduleTimePeriodConverted += 'on' - # } else {$ScheduleTimePeriodConverted += 'off'} - # } $ScheduleTimePeriod += $Match.Value } } - foreach ($OBJ in $Hours24.GetEnumerator()) { - - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $ScheduleTimePeriod $TableParams = @{ Name = "Backup Window - $($Bkjob.Name)" diff --git a/Src/Private/Get-AbrVbrInfrastructureSummary.ps1 b/Src/Private/Get-AbrVbrInfrastructureSummary.ps1 index 4590e5b..c86c415 100644 --- a/Src/Private/Get-AbrVbrInfrastructureSummary.ps1 +++ b/Src/Private/Get-AbrVbrInfrastructureSummary.ps1 @@ -89,51 +89,16 @@ function Get-AbrVbrInfrastructureSummary { $inObj.Remove('Capacity Licenses (Total/Used)') $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name BackupInfrastructure -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Infrastructure' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'BackupInfrastructure' -XField 'Category' -YField 'Value' -ChartLegendName 'Infrastructure' + } catch { + Write-PscriboMessage -IsWarning "Backup Infrastructure chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Backup Infrastructure Inventory' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Backup Infrastructure - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Backup Infrastructure - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams diff --git a/Src/Private/Get-AbrVbrInstalledLicense.ps1 b/Src/Private/Get-AbrVbrInstalledLicense.ps1 index 3593709..46ad1c9 100644 --- a/Src/Private/Get-AbrVbrInstalledLicense.ps1 +++ b/Src/Private/Get-AbrVbrInstalledLicense.ps1 @@ -111,51 +111,16 @@ function Get-AbrVbrInstalledLicense { try { $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name InstanceLicenseUsage -Width 600 -Height 400 + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'InstanceLicenseUsage' -XField 'Category' -YField 'Value' -ChartLegendName 'Category' - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Category' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + } catch { + Write-PscriboMessage -IsWarning "Instance License Usage chart section: $($_.Exception.Message)" } } if ($OutObj) { Section -Style NOTOCHeading5 -ExcludeFromTOC 'Instance License Usage' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Instance License Usage - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Instance License Usage - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams @@ -235,53 +200,19 @@ function Get-AbrVbrInstalledLicense { if ($Report.ShowTableCaptions) { $TableParams['Caption'] = "- $($TableParams.Name)" } - try { - $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - - $exampleChart = New-Chart -Name CPUSocketUsage -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Category' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams + if ($Options.EnableCharts) { + try { + $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'CPUSocketUsage' -XField 'Category' -YField 'Value' -ChartLegendName 'Category' + } catch { + Write-PscriboMessage -IsWarning "CPU Socket Usage chart section: $($_.Exception.Message)" } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) } if ($OutObj) { Section -Style NOTOCHeading5 -ExcludeFromTOC 'CPU Socket License Usage' { if ($chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'CPU Socket License Usage - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'CPU Socket License Usage - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } $OutObj | Table @TableParams } @@ -320,53 +251,22 @@ function Get-AbrVbrInstalledLicense { if ($Report.ShowTableCaptions) { $TableParams['Caption'] = "- $($TableParams.Name)" } - try { - $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - - $exampleChart = New-Chart -Name CapacityLicenseUsage -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru + if ($Options.EnableCharts) { + if ($Options.EnableCharts) { + try { + $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Category' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'CapacityLicenseUsage' -XField 'Category' -YField 'Value' -ChartLegendName 'Category' - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) + } catch { + Write-PscriboMessage -IsWarning "Capacity License Usage chart section: $($_.Exception.Message)" + } } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) } if ($OutObj) { Section -Style NOTOCHeading5 -ExcludeFromTOC 'Capacity License Usage' { if ($chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Capacity License Usage - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Capacity License Usage - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } $OutObj | Table @TableParams } diff --git a/Src/Private/Get-AbrVbrInventorySummary.ps1 b/Src/Private/Get-AbrVbrInventorySummary.ps1 index d1f4370..22f4e67 100644 --- a/Src/Private/Get-AbrVbrInventorySummary.ps1 +++ b/Src/Private/Get-AbrVbrInventorySummary.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrInventorySummary { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.8.3 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -76,51 +76,16 @@ function Get-AbrVbrInventorySummary { try { $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name Inventory -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Infrastructure' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'Inventory' -XField 'Category' -YField 'Value' -ChartLegendName 'Infrastructure' + } catch { + Write-PscriboMessage -IsWarning "Inventory chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Inventory' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Inventory - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Inventory - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams diff --git a/Src/Private/Get-AbrVbrNetworkTrafficRule.ps1 b/Src/Private/Get-AbrVbrNetworkTrafficRule.ps1 index 75aa429..90b63d5 100644 --- a/Src/Private/Get-AbrVbrNetworkTrafficRule.ps1 +++ b/Src/Private/Get-AbrVbrNetworkTrafficRule.ps1 @@ -64,51 +64,10 @@ function Get-AbrVbrNetworkTrafficRule { Text 'Permited \' -Color 81BC50 -Bold Text ' Denied' -Color dddf62 -Bold } - $OutObj = @() - try { - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } - $ScheduleTimePeriod = $TrafficRule.ThrottlingWindowOptions -split '(.{48})' | Where-Object {$_} - foreach ($OBJ in $Hours24.GetEnumerator()) { + try { - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $TrafficRule.ThrottlingWindowOptions $TableParams = @{ Name = "Throttling Windows - $($TrafficRule.Name)" diff --git a/Src/Private/Get-AbrVbrReplInfraSummary.ps1 b/Src/Private/Get-AbrVbrReplInfraSummary.ps1 index c9201c3..fda1d3f 100644 --- a/Src/Private/Get-AbrVbrReplInfraSummary.ps1 +++ b/Src/Private/Get-AbrVbrReplInfraSummary.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrReplInfraSummary { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.7.1 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -47,51 +47,16 @@ function Get-AbrVbrReplInfraSummary { try { $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name ReplicationInventory -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Infrastructure' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'ReplicationInventory' -XField 'Category' -YField 'Value' -ChartLegendName 'Infrastructure' + } catch { + Write-PscriboMessage -IsWarning "Replication Inventory chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Replication Inventory' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Replication Inventory - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Replication Inventory - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams diff --git a/Src/Private/Get-AbrVbrRepljobHyperV.ps1 b/Src/Private/Get-AbrVbrRepljobHyperV.ps1 index 3223c0d..ae822f8 100644 --- a/Src/Private/Get-AbrVbrRepljobHyperV.ps1 +++ b/Src/Private/Get-AbrVbrRepljobHyperV.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrRepljobHyperV { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.8.0 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -826,36 +826,9 @@ function Get-AbrVbrRepljobHyperV { Text 'Permited \' -Color 81BC50 -Bold Text ' Denied' -Color dddf62 -Bold } - $OutObj = @() try { - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } $ScheduleTimePeriod = @() + $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' foreach ($Day in $Days) { $Regex = [Regex]::new("(?<=<$Day>)(.*)(?=)") @@ -865,31 +838,11 @@ function Get-AbrVbrRepljobHyperV { $Match = $Regex.Match($BackupWindow) if($Match.Success) { - $ScheduleTimePeriodConverted = @() - - # foreach ($Val in $Match.Value.Split(',')) { - # if ($Val -eq 0) { - # $ScheduleTimePeriodConverted += 'on' - # } else {$ScheduleTimePeriodConverted += 'off'} - # } $ScheduleTimePeriod += $Match.Value } } - foreach ($OBJ in $Hours24.GetEnumerator()) { - - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $ScheduleTimePeriod $TableParams = @{ Name = "Backup Window - $($Bkjob.Name)" diff --git a/Src/Private/Get-AbrVbrRepljobVMware.ps1 b/Src/Private/Get-AbrVbrRepljobVMware.ps1 index 9c91876..aa9ee7c 100644 --- a/Src/Private/Get-AbrVbrRepljobVMware.ps1 +++ b/Src/Private/Get-AbrVbrRepljobVMware.ps1 @@ -834,34 +834,8 @@ function Get-AbrVbrRepljobVMware { } $OutObj = @() try { - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } $ScheduleTimePeriod = @() + $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' foreach ($Day in $Days) { $Regex = [Regex]::new("(?<=<$Day>)(.*)(?=)") @@ -871,31 +845,11 @@ function Get-AbrVbrRepljobVMware { $Match = $Regex.Match($BackupWindow) if($Match.Success) { - $ScheduleTimePeriodConverted = @() - - # foreach ($Val in $Match.Value.Split(',')) { - # if ($Val -eq 0) { - # $ScheduleTimePeriodConverted += 'on' - # } else {$ScheduleTimePeriodConverted += 'off'} - # } $ScheduleTimePeriod += $Match.Value } } - foreach ($OBJ in $Hours24.GetEnumerator()) { - - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $ScheduleTimePeriod $TableParams = @{ Name = "Backup Window - $($Bkjob.Name)" diff --git a/Src/Private/Get-AbrVbrScaleOutRepository.ps1 b/Src/Private/Get-AbrVbrScaleOutRepository.ps1 index 9b2a4f8..63afa47 100644 --- a/Src/Private/Get-AbrVbrScaleOutRepository.ps1 +++ b/Src/Private/Get-AbrVbrScaleOutRepository.ps1 @@ -227,49 +227,7 @@ function Get-AbrVbrScaleOutRepository { } $OutObj = @() try { - $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' - $Hours24 = [ordered]@{ - 0 = 12 - 1 = 1 - 2 = 2 - 3 = 3 - 4 = 4 - 5 = 5 - 6 = 6 - 7 = 7 - 8 = 8 - 9 = 9 - 10 = 10 - 11 = 11 - 12 = 12 - 13 = 1 - 14 = 2 - 15 = 3 - 16 = 4 - 17 = 5 - 18 = 6 - 19 = 7 - 20 = 8 - 21 = 9 - 22 = 10 - 23 = 11 - } - $ScheduleTimePeriod = $BackupRepo.OffloadWindowOptions -split '(.{48})' | Where-Object {$_} - - foreach ($OBJ in $Hours24.GetEnumerator()) { - - $inObj = [ordered] @{ - 'H' = $OBJ.Value - 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] - 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] - 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] - 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] - 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] - 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] - 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] - } - $OutObj += $inobj - } + $OutObj = Get-WindowsTimePeriod -InputTimePeriod $BackupRepo.OffloadWindowOptions $TableParams = @{ Name = "Offload Window - $(($CapacityExtent.Repository).Name)" diff --git a/Src/Private/Get-AbrVbrSecurityCompliance.ps1 b/Src/Private/Get-AbrVbrSecurityCompliance.ps1 index 82045eb..4c343d8 100644 --- a/Src/Private/Get-AbrVbrSecurityCompliance.ps1 +++ b/Src/Private/Get-AbrVbrSecurityCompliance.ps1 @@ -107,56 +107,19 @@ function Get-AbrVbrSecurityCompliance { if ($Report.ShowTableCaptions) { $TableParams['Caption'] = "- $($TableParams.Name)" } - if ($Options.EnableCharts) { - try { - $sampleData = $OutObj.status | Group-Object - $exampleChart = New-Chart -Name BackupJobs -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'SecurityCompliance' - AxisXTitle = 'Status' - AxisYTitle = 'Count' - NoAxisXMajorGridLines = $true - NoAxisYMajorGridLines = $true - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Name' - YField = 'Count' - Palette = 'Green' - ColorPerDataPoint = $true - } - $sampleData | Add-ColumnChartSeries @addChartSeriesParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'SecurityCompliance' - Text = 'Security & Compliance' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru + try { + $sampleData = $OutObj.status | Group-Object - if ($PassThru) - { - Write-Output -InputObject $chartFileItem - } - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) - } + $chartFileItem = Get-ColumnChart -SampleData $sampleData -ChartName 'SecurityCompliance' -XField 'Name' -YField 'Count' -ChartAreaName 'Infrastructure' -AxisXTitle 'Status' -AxisYTitle 'Count' -ChartTitleName 'SecurityCompliance' -ChartTitleText 'Best Practices' + } catch { + Write-PscriboMessage -IsWarning "Security & Compliance chart section: $($_.Exception.Message)" } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Security & Compliance' { if ($Options.EnableCharts -and $chartFileItem -and ($OutObj.count | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Security & Compliance - Chart' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Security & Compliance - Chart' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Sort-Object -Property 'Best Practice' | Table @TableParams diff --git a/Src/Private/Get-AbrVbrStorageInfraSummary.ps1 b/Src/Private/Get-AbrVbrStorageInfraSummary.ps1 index 36a65fb..042cd67 100644 --- a/Src/Private/Get-AbrVbrStorageInfraSummary.ps1 +++ b/Src/Private/Get-AbrVbrStorageInfraSummary.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrStorageInfraSummary { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.5.5 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -56,51 +56,16 @@ function Get-AbrVbrStorageInfraSummary { try { $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name StorageInfrastructure -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Infrastructure' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'StorageInfrastructure' -XField 'Category' -YField 'Value' -ChartLegendName 'Infrastructure' + } catch { + Write-PscriboMessage -IsWarning "Storage Infrastructure chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Storage Infrastructure Inventory' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Storage Infrastructure Inventory - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Storage Infrastructure Inventory - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams diff --git a/Src/Private/Get-AbrVbrTapeInfraSummary.ps1 b/Src/Private/Get-AbrVbrTapeInfraSummary.ps1 index f031ab6..deb4b7d 100644 --- a/Src/Private/Get-AbrVbrTapeInfraSummary.ps1 +++ b/Src/Private/Get-AbrVbrTapeInfraSummary.ps1 @@ -6,7 +6,7 @@ function Get-AbrVbrTapeInfraSummary { .DESCRIPTION Documents the configuration of Veeam VBR in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.7.1 + Version: 0.8.4 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -60,51 +60,16 @@ function Get-AbrVbrTapeInfraSummary { try { $sampleData = $inObj.GetEnumerator() | Select-Object @{ Name = 'Category'; Expression = {$_.key}},@{ Name = 'Value'; Expression = {$_.value}} | Sort-Object -Property 'Category' - $exampleChart = New-Chart -Name TapeInfrastructure -Width 600 -Height 400 - - $addChartAreaParams = @{ - Chart = $exampleChart - Name = 'exampleChartArea' - } - $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru - - $addChartSeriesParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = 'exampleChartSeries' - XField = 'Category' - YField = 'Value' - Palette = 'Green' - ColorPerDataPoint = $true - } - $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru - - $addChartLegendParams = @{ - Chart = $exampleChart - Name = 'Infrastructure' - TitleAlignment = 'Center' - } - Add-ChartLegend @addChartLegendParams - - $addChartTitleParams = @{ - Chart = $exampleChart - ChartArea = $exampleChartArea - Name = ' ' - Text = ' ' - Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) - } - Add-ChartTitle @addChartTitleParams - - $chartFileItem = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru - } - catch { - Write-PscriboMessage -IsWarning $($_.Exception.Message) + $chartFileItem = Get-PieChart -SampleData $sampleData -ChartName 'TapeInfrastructure' -XField 'Category' -YField 'Value' -ChartLegendName 'Infrastructure' + } catch { + Write-PscriboMessage -IsWarning "Tape Infrastructure chart section: $($_.Exception.Message)" } } + if ($OutObj) { Section -Style NOTOCHeading3 -ExcludeFromTOC 'Tape Infrastructure' { if ($Options.EnableCharts -and $chartFileItem -and ($inObj.Values | Measure-Object -Sum).Sum -ne 0) { - Image -Text 'Tape Infrastructure - Diagram' -Align 'Center' -Percent 100 -Path $chartFileItem + Image -Text 'Tape Infrastructure - Diagram' -Align 'Center' -Percent 100 -Base64 $chartFileItem } BlankLine $OutObj | Table @TableParams diff --git a/Src/Private/SharedUtilsFunctions.ps1 b/Src/Private/SharedUtilsFunctions.ps1 index f111178..ec8f5b2 100644 --- a/Src/Private/SharedUtilsFunctions.ps1 +++ b/Src/Private/SharedUtilsFunctions.ps1 @@ -261,4 +261,248 @@ function Get-ImagePercent { } else { return 20 } +} # end + +function Get-PieChart { + <# + .SYNOPSIS + Used by As Built Report to generate PScriboChart pie charts. + .DESCRIPTION + .NOTES + Version: 0.1.0 + Author: Jonathan Colon + .EXAMPLE + .LINK + #> + [CmdletBinding()] + [OutputType([System.String])] + Param + ( + [Parameter ( + Position = 0, + Mandatory)] + [System.Array] + $SampleData, + [String] + $ChartName, + [String] + $XField, + [String] + $YField, + [String] + $ChartLegendName, + [String] + $ChartLegendAlignment = 'Center', + [String] + $ChartTitleName = ' ', + [String] + $ChartTitleText = ' ', + [int] + $Width = 600, + [int] + $Height = 400 + ) + + $exampleChart = New-Chart -Name $ChartName -Width $Width -Height $Height + + $addChartAreaParams = @{ + Chart = $exampleChart + Name = 'exampleChartArea' + } + $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru + + $addChartSeriesParams = @{ + Chart = $exampleChart + ChartArea = $exampleChartArea + Name = 'exampleChartSeries' + XField = $XField + YField = $YField + Palette = 'Green' + ColorPerDataPoint = $true + } + $exampleChartSeries = $sampleData | Add-PieChartSeries @addChartSeriesParams -PassThru + + $addChartLegendParams = @{ + Chart = $exampleChart + Name = $ChartLegendName + TitleAlignment = $ChartLegendAlignment + } + Add-ChartLegend @addChartLegendParams + + $addChartTitleParams = @{ + Chart = $exampleChart + ChartArea = $exampleChartArea + Name = $ChartTitleName + Text = $ChartTitleText + Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) + } + Add-ChartTitle @addChartTitleParams + + $ChartImage = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru + + $Base64Image = [convert]::ToBase64String((get-content $ChartImage -encoding byte)) + + Remove-Item -Path $ChartImage.FullName + + return $Base64Image + +} # end + +function Get-ColumnChart { + <# + .SYNOPSIS + Used by As Built Report to generate PScriboChart column charts. + .DESCRIPTION + .NOTES + Version: 0.1.0 + Author: Jonathan Colon + .EXAMPLE + .LINK + #> + [CmdletBinding()] + [OutputType([System.String])] + Param + ( + [Parameter ( + Position = 0, + Mandatory)] + [System.Array] + $SampleData, + [String] + $ChartName, + [String] + $AxisXTitle, + [String] + $AxisYTitle, + [String] + $XField, + [String] + $YField, + [String] + $ChartAreaName, + [String] + $ChartTitleName = ' ', + [String] + $ChartTitleText = ' ', + [int] + $Width = 600, + [int] + $Height = 400 + ) + + $exampleChart = New-Chart -Name $ChartName -Width $Width -Height $Height + + $addChartAreaParams = @{ + Chart = $exampleChart + Name = $ChartAreaName + AxisXTitle = $AxisXTitle + AxisYTitle = $AxisYTitle + NoAxisXMajorGridLines = $true + NoAxisYMajorGridLines = $true + } + $exampleChartArea = Add-ChartArea @addChartAreaParams -PassThru + + $addChartSeriesParams = @{ + Chart = $exampleChart + ChartArea = $exampleChartArea + Name = 'exampleChartSeries' + XField = $XField + YField = $YField + Palette = 'Green' + ColorPerDataPoint = $true + } + $sampleData | Add-ColumnChartSeries @addChartSeriesParams + + $addChartTitleParams = @{ + Chart = $exampleChart + ChartArea = $exampleChartArea + Name = $ChartTitleName + Text = $ChartTitleText + Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList @('Arial', '12', [System.Drawing.FontStyle]::Bold) + } + Add-ChartTitle @addChartTitleParams + + $ChartImage = Export-Chart -Chart $exampleChart -Path (Get-Location).Path -Format "PNG" -PassThru + + if ($PassThru) + { + Write-Output -InputObject $chartFileItem + } + + $Base64Image = [convert]::ToBase64String((get-content $ChartImage -encoding byte)) + + Remove-Item -Path $ChartImage.FullName + + return $Base64Image + +} # end + +function Get-WindowsTimePeriod { + <# + .SYNOPSIS + Used by As Built Report to generate time period table. + .DESCRIPTION + .NOTES + Version: 0.1.0 + Author: Jonathan Colon + .EXAMPLE + .LINK + #> + [CmdletBinding()] + Param + ( + [Parameter ( + Position = 0, + Mandatory)] + [System.Array] + $InputTimePeriod + ) + + $OutObj = @() + $Days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' + $Hours24 = [ordered]@{ + 0 = 12 + 1 = 1 + 2 = 2 + 3 = 3 + 4 = 4 + 5 = 5 + 6 = 6 + 7 = 7 + 8 = 8 + 9 = 9 + 10 = 10 + 11 = 11 + 12 = 12 + 13 = 1 + 14 = 2 + 15 = 3 + 16 = 4 + 17 = 5 + 18 = 6 + 19 = 7 + 20 = 8 + 21 = 9 + 22 = 10 + 23 = 11 + } + $ScheduleTimePeriod = $InputTimePeriod -split '(.{48})' | Where-Object {$_} + + foreach ($OBJ in $Hours24.GetEnumerator()) { + + $inObj = [ordered] @{ + 'H' = $OBJ.Value + 'Sun' = $ScheduleTimePeriod[0].Split(',')[$OBJ.Key] + 'Mon' = $ScheduleTimePeriod[1].Split(',')[$OBJ.Key] + 'Tue' = $ScheduleTimePeriod[2].Split(',')[$OBJ.Key] + 'Wed' = $ScheduleTimePeriod[3].Split(',')[$OBJ.Key] + 'Thu' = $ScheduleTimePeriod[4].Split(',')[$OBJ.Key] + 'Fri' = $ScheduleTimePeriod[5].Split(',')[$OBJ.Key] + 'Sat' = $ScheduleTimePeriod[6].Split(',')[$OBJ.Key] + } + $OutObj += $inobj + } + + return $OutObj + } # end \ No newline at end of file