diff --git a/.github/workflows/PSScriptAnalyzer.yml b/.github/workflows/PSScriptAnalyzer.yml index 3c79c0e..7554e95 100644 --- a/.github/workflows/PSScriptAnalyzer.yml +++ b/.github/workflows/PSScriptAnalyzer.yml @@ -5,7 +5,7 @@ jobs: name: Run PSScriptAnalyzer runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: lint uses: alagoutte/github-action-psscriptanalyzer@master with: diff --git a/.github/workflows/Pester.yml b/.github/workflows/Pester.yml index 3703e67..10ad496 100644 --- a/.github/workflows/Pester.yml +++ b/.github/workflows/Pester.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Set up PowerShell Gallery run: | @@ -68,7 +68,7 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: test-results-${{ matrix.os }}-${{ matrix.shell }} path: Tests/testResults.xml diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 39a2492..3f46982 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -8,7 +8,7 @@ jobs: publish-to-gallery: runs-on: windows-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Set PSRepository to Trusted for PowerShell Gallery shell: pwsh run: | diff --git a/AsBuiltReport.Microsoft.AD/AsBuiltReport.Microsoft.AD.json b/AsBuiltReport.Microsoft.AD/AsBuiltReport.Microsoft.AD.json index 4a34316..7f55b40 100644 --- a/AsBuiltReport.Microsoft.AD/AsBuiltReport.Microsoft.AD.json +++ b/AsBuiltReport.Microsoft.AD/AsBuiltReport.Microsoft.AD.json @@ -45,7 +45,8 @@ "SignatureAuthorName": "", "SignatureCompanyName": "", "JobsTimeOut": 900, - "DCStatusPingCount": 2 + "DCStatusPingCount": 2, + "DisableDiagramMainLogo": false }, "InfoLevel": { "_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed", diff --git a/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/Get-AbrDiagrammer.ps1 b/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/Get-AbrDiagrammer.ps1 index ee7bca4..270fb14 100644 --- a/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/Get-AbrDiagrammer.ps1 +++ b/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/Get-AbrDiagrammer.ps1 @@ -115,6 +115,10 @@ function Get-AbrDiagrammer { $DiagramParams.Add('CompanyName', $Options.SignatureCompanyName) } + if ($Options.DisableDiagramMainLogo) { + $DiagramParams.Add('DisableMainDiagramLogo', $True) + } + try { foreach ($Format in $DiagramFormat) { if ($Format -eq 'base64') { diff --git a/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/New-AbrADDiagram.ps1 b/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/New-AbrADDiagram.ps1 index 1180e5d..88d0a2e 100644 --- a/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/New-AbrADDiagram.ps1 +++ b/AsBuiltReport.Microsoft.AD/Src/Private/Diagram/New-AbrADDiagram.ps1 @@ -53,6 +53,8 @@ function New-AbrADDiagram { Control to enable subgraph debugging ( Subgraph Lines ). .PARAMETER EnableErrorDebug Control to enable error debugging. + .PARAMETER DisableMainDiagramLogo + Switch to disable rendering the main diagram logo. .PARAMETER AuthorName Allow to set footer signature Author Name. .PARAMETER CompanyName @@ -155,6 +157,12 @@ function New-AbrADDiagram { [ValidateSet('left-to-right', 'top-to-bottom')] [string] $Direction = 'top-to-bottom', + [Parameter( + Mandatory = $false, + HelpMessage = 'Disable the Main Diagram Logo' + )] + [Switch] $DisableMainDiagramLogo, + [Parameter( Mandatory = $false, HelpMessage = 'Please provide the path to the diagram output file' @@ -510,8 +518,15 @@ function New-AbrADDiagram { Write-Verbose $reportTranslate.NewADDiagram.genDiagramSignature + # Subgraph MainGraph used to draw the main drawboard. + if ($DisableMainDiagramLogo) { + $FormatedMainLogo = '' + } else { + $FormatedMainLogo = Add-HtmlLabel -ImagesObj $Images -Label $MainGraphLabel -IconType $CustomLogo -IconDebug $IconDebug -IconWidth 250 -IconHeight 80 -Fontsize 24 -FontName 'Segoe UI Bold' -FontColor $Fontcolor -TableBackgroundColor $MainGraphBGColor -CellBackgroundColor $MainGraphBGColor + } + # Main Graph SubGraph - SubGraph MainGraph -Attributes @{Label = (Add-HtmlLabel -ImagesObj $Images -Label $MainGraphLabel -IconType $CustomLogo -IconDebug $IconDebug -IconWidth 250 -IconHeight 80 -Fontsize 24 -FontName 'Segoe UI Bold' -FontColor $Fontcolor -TableBackgroundColor $MainGraphBGColor -CellBackgroundColor $MainGraphBGColor); fontsize = 22; penwidth = 0; labelloc = 't'; labeljust = 'c' } { + SubGraph MainGraph -Attributes @{Label = $FormatedMainLogo; fontsize = 22; penwidth = 0; labelloc = 't'; labeljust = 'c' } { Write-Verbose $reportTranslate.NewADDiagram.genDiagramMain $script:ForestRoot = $ADSystem.Name.ToString().ToUpper() diff --git a/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-HashToYN.ps1 b/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-HashToYN.ps1 index 99c1f00..112c250 100644 --- a/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-HashToYN.ps1 +++ b/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-HashToYN.ps1 @@ -3,10 +3,13 @@ function ConvertTo-HashToYN { .SYNOPSIS Used by As Built Report to convert array content true or false automatically to Yes or No. .DESCRIPTION - + Used by As Built Report to convert array content true or false automatically to Yes or No. + Now also strips non-printable ASCII characters from string values while creating the array hash. + This is required for Word Document Output as PSCribo cannot create Word documents with non-ASCII characters .NOTES - Version: 0.2.0 + Version: 0.1.1 Author: Jonathan Colon + Changes: 0.1.1 - Updated to include non-unicode character string cleaning. Graham Flynn - 30/07/2025 .EXAMPLE @@ -22,14 +25,31 @@ function ConvertTo-HashToYN { ) $result = [ordered] @{} + foreach ($i in $TEXT.GetEnumerator()) { try { - $result.add($i.Key, (ConvertTo-TextYN $i.Value)) + $valueToProcess = $i.Value + + # Check if the value is a string before attempting to clean it + if ($valueToProcess -is [string]) { + $valueToProcess = $valueToProcess | Remove-NonPrintableAscii + } + + $convertedValue = ConvertTo-TextYN $valueToProcess + + $result.add($i.Key, $convertedValue) } catch { - $result.add($i.Key, ($i.Value)) + # If ConvertTo-TextYN fails, still try to clean the original value if it's a string + $originalValue = $i.Value + if ($originalValue -is [string]) { + $originalValue = $originalValue | Remove-NonPrintableAscii + } + $result.add($i.Key, ($originalValue)) # Add the (potentially cleaned) original value } } if ($result) { - $result - } else { $TEXT } + return $result + } else { + return $TEXT + } } # end \ No newline at end of file diff --git a/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-TextYN.ps1 b/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-TextYN.ps1 index fa393e2..36c280c 100644 --- a/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-TextYN.ps1 +++ b/AsBuiltReport.Microsoft.AD/Src/Private/Tools/ConvertTo-TextYN.ps1 @@ -20,6 +20,7 @@ function ConvertTo-TextYN { Position = 0, Mandatory)] [AllowEmptyString()] + [AllowNull()] [string] $TEXT ) diff --git a/AsBuiltReport.Microsoft.AD/Src/Private/Tools/Remove-NonPrintableAscii.ps1 b/AsBuiltReport.Microsoft.AD/Src/Private/Tools/Remove-NonPrintableAscii.ps1 new file mode 100644 index 0000000..5f30966 --- /dev/null +++ b/AsBuiltReport.Microsoft.AD/Src/Private/Tools/Remove-NonPrintableAscii.ps1 @@ -0,0 +1,49 @@ +function Remove-NonPrintableAscii { + <# + .SYNOPSIS + Removes non-printable ASCII characters from a string. + .DESCRIPTION + This function takes a string as input and returns a new string + where all characters outside the printable ASCII range (ASCII 32-126) + have been removed. If the input is null or empty, it returns an empty string. + .PARAMETER InputString + The string from which to remove non-printable ASCII characters. + .EXAMPLE + Remove-NonPrintableAscii -InputString "Hello`nWorld`t!" + # Output: "HelloWorld!" + + .EXAMPLE + "This string has a null character: `0" | Remove-NonPrintableAscii + # Output: "This string has a null character: " + + .EXAMPLE + $null | Remove-NonPrintableAscii + # Output: "" (empty string) + + .EXAMPLE + "" | Remove-NonPrintableAscii + # Output: "" (empty string) + #> + [CmdletBinding(SupportsShouldProcess = $true)] + [OutputType([String])] + + param ( + [Parameter(ValueFromPipeline = $true)] + [string]$InputString + ) + + process { + if ($PSCmdlet.ShouldProcess($InputString, 'Remove non-printable ASCII characters')) { + # Check if the input string is null or empty. + # If it is, return an empty string immediately to avoid errors. + if ([string]::IsNullOrEmpty($InputString)) { + return '' + } + + # Regular expression to match any character that is NOT a printable ASCII character. + # [^\x20-\x7E] matches any character that is not in the range of ASCII 32 (space) to 126 (tilde). + $cleanedString = $InputString -replace '[^\x20-\x7E]', '' + return $cleanedString + } + } +} \ No newline at end of file diff --git a/AsBuiltReport.Microsoft.AD/Src/Public/Get-AbrAdLog.ps1 b/AsBuiltReport.Microsoft.AD/Src/Public/Get-AbrAdLog.ps1 index 49d29ad..e9c694e 100644 --- a/AsBuiltReport.Microsoft.AD/Src/Public/Get-AbrAdLog.ps1 +++ b/AsBuiltReport.Microsoft.AD/Src/Public/Get-AbrAdLog.ps1 @@ -26,7 +26,7 @@ function Get-AbrAdLog { Saves a full diagnostic JSON (with stack traces) to C:\Logs and returns the object to the pipeline. .NOTES - Version: 0.1.0 + Version: 1.0.1 Author: Jonathan Colon Github: rebelinux .LINK diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e39e9b..e31e52b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ##### This project is community maintained and has no sponsorship from Microsoft, its employees or any of its affiliates. -## [1.0.1] - unreleased +## [1.0.1] - 2026-06-22 ### Added @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump module version to `1.0.1` - Upgrade AsBuiltReport.Diagram module to version `1.0.8` - Upgrade AsBuiltReport.Chart module to version `0.3.3` +- Set an option to enable/disable the main logo of the diagrams +- Update github actions to latest releases ### Fixed @@ -25,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add success message logging for completed commands in `Invoke-CommandWithTimeout` function - Update localization files to include NoData messages and improve key matching in tests - Fix [255](https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.AD/issues/255) +- Fix: remove non-printable ASCII characters from a string ## [1.0.0] - 2026-05-02