From 4f5533a636af72a83339fbac90f50e69cd770eb5 Mon Sep 17 00:00:00 2001 From: Chris Arceneaux Date: Wed, 14 Jan 2026 14:21:22 -0800 Subject: [PATCH 1/4] Test linting Signed-off-by: Chris Arceneaux --- .github/workflows/powershell-lint.yml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/powershell-lint.yml diff --git a/.github/workflows/powershell-lint.yml b/.github/workflows/powershell-lint.yml new file mode 100644 index 0000000..f40d70c --- /dev/null +++ b/.github/workflows/powershell-lint.yml @@ -0,0 +1,50 @@ +name: PowerShell Linting + +on: + pull_request: + branches: + - master + paths: + - '**.ps1' + - '**.psm1' + - '**.psd1' + workflow_dispatch: + +jobs: + lint: + name: Run PSScriptAnalyzer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install PSScriptAnalyzer + shell: pwsh + run: | + Set-PSRepository PSGallery -InstallationPolicy Trusted + Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser + + - name: Run PSScriptAnalyzer + shell: pwsh + run: | + $results = @() + $files = Get-ChildItem -Path . -Recurse -Include *.ps1,*.psm1,*.psd1 | Where-Object { $_.FullName -notmatch '[\\/]\.git[\\/]' } + + foreach ($file in $files) { + Write-Host "Analyzing: $($file.FullName)" + $analysis = Invoke-ScriptAnalyzer -Path $file.FullName -Severity Error,Warning + if ($analysis) { + $results += $analysis + foreach ($result in $analysis) { + Write-Host "::error file=$($file.Name),line=$($result.Line),col=$($result.Column)::$($result.Message)" + } + } + } + + if ($results.Count -gt 0) { + Write-Host "`n$($results.Count) issue(s) found" + exit 1 + } else { + Write-Host "`nNo issues found" + } From 8ac00401502cc111379deb22806c12222a444d46 Mon Sep 17 00:00:00 2001 From: Chris Arceneaux Date: Thu, 15 Jan 2026 08:52:39 -0800 Subject: [PATCH 2/4] Limit to changed Instead of linting all scripts in the repo - there are a LOT - only lint changes. Signed-off-by: Chris Arceneaux --- .github/workflows/powershell-lint.yml | 30 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/powershell-lint.yml b/.github/workflows/powershell-lint.yml index f40d70c..a0ec74f 100644 --- a/.github/workflows/powershell-lint.yml +++ b/.github/workflows/powershell-lint.yml @@ -29,15 +29,27 @@ jobs: shell: pwsh run: | $results = @() - $files = Get-ChildItem -Path . -Recurse -Include *.ps1,*.psm1,*.psd1 | Where-Object { $_.FullName -notmatch '[\\/]\.git[\\/]' } - - foreach ($file in $files) { - Write-Host "Analyzing: $($file.FullName)" - $analysis = Invoke-ScriptAnalyzer -Path $file.FullName -Severity Error,Warning - if ($analysis) { - $results += $analysis - foreach ($result in $analysis) { - Write-Host "::error file=$($file.Name),line=$($result.Line),col=$($result.Column)::$($result.Message)" + + # Get list of changed PowerShell files in the PR + $changedFiles = git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD | Where-Object { $_ -match '\.(ps1|psm1|psd1)$' } + + if (-not $changedFiles) { + Write-Host "No PowerShell files changed in this PR" + exit 0 + } + + Write-Host "Found $($changedFiles.Count) changed PowerShell file(s)" + + foreach ($file in $changedFiles) { + if (Test-Path $file) { + Write-Host "Analyzing: $file" + $analysis = Invoke-ScriptAnalyzer -Path $file -Severity Error,Warning + if ($analysis) { + $results += $analysis + foreach ($result in $analysis) { + $fileName = Split-Path $file -Leaf + Write-Host "::error file=$fileName,line=$($result.Line),col=$($result.Column)::$($result.Message)" + } } } } From b2232b94653eafe9f527313ba26937e44836df17 Mon Sep 17 00:00:00 2001 From: Chris Arceneaux Date: Wed, 11 Mar 2026 15:52:59 -0400 Subject: [PATCH 3/4] Fix to remove all apps - Previous method left 1 auxiliary backup application that still needed to be removed. - Updated logic to run if ANY auxiliary backup applications are found Signed-off-by: Chris Arceneaux --- VB365-KB4821/Find-MultipleBackupApplications.ps1 | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/VB365-KB4821/Find-MultipleBackupApplications.ps1 b/VB365-KB4821/Find-MultipleBackupApplications.ps1 index 09be954..5a96402 100644 --- a/VB365-KB4821/Find-MultipleBackupApplications.ps1 +++ b/VB365-KB4821/Find-MultipleBackupApplications.ps1 @@ -86,23 +86,20 @@ foreach ($org in $orgs) { # check if multiple backup applications are used Write-Verbose "Backup Applications found: $($apps.Count)" - if ($apps.Count -gt 1) { + if ($apps.Count -gt 0) { # adding field to show if backup application was removed $apps | Add-Member -MemberType NoteProperty -Name "RemovedFromVeeam" -Value $false # remove extra backup applications if the Fix flag is set if ($Fix) { Write-Verbose "Fix flag is set. Removing multiple backup applications for organization $($org.Name)..." - # $j = 1 skipping first backup application - $appsToRemove = $apps | Select-Object -Skip 1 - foreach ($app in $appsToRemove) { + foreach ($app in $apps) { Write-Verbose "Removing backup application $($app.ApplicationId)" - Remove-VBOBackupApplication -Organization $org -BackupApplication $app -Confirm:$false + Remove-VBOBackupApplication -Organization $org -BackupApplication $app -Confirm:$false | Out-Null # noting that application was removed in output $app.RemovedFromVeeam = $true } - Clear-Variable -Name appsToRemove } $object = [PSCustomObject] @{ @@ -115,10 +112,6 @@ foreach ($org in $orgs) { Clear-Variable -Name apps } -if ($output.Count -eq 0) { - Write-Verbose "No organizations with multiple backup applications found. Moving along..." -} - # logging out of Veeam session Disconnect-VBOServer From 9534c699c1bfdcb86e178938e37ddb46347667c5 Mon Sep 17 00:00:00 2001 From: Chris Arceneaux Date: Wed, 11 Mar 2026 15:55:32 -0400 Subject: [PATCH 4/4] Removing file not affiliated with PR Signed-off-by: Chris Arceneaux --- .github/workflows/powershell-lint.yml | 62 --------------------------- 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/powershell-lint.yml diff --git a/.github/workflows/powershell-lint.yml b/.github/workflows/powershell-lint.yml deleted file mode 100644 index a0ec74f..0000000 --- a/.github/workflows/powershell-lint.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: PowerShell Linting - -on: - pull_request: - branches: - - master - paths: - - '**.ps1' - - '**.psm1' - - '**.psd1' - workflow_dispatch: - -jobs: - lint: - name: Run PSScriptAnalyzer - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Install PSScriptAnalyzer - shell: pwsh - run: | - Set-PSRepository PSGallery -InstallationPolicy Trusted - Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser - - - name: Run PSScriptAnalyzer - shell: pwsh - run: | - $results = @() - - # Get list of changed PowerShell files in the PR - $changedFiles = git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD | Where-Object { $_ -match '\.(ps1|psm1|psd1)$' } - - if (-not $changedFiles) { - Write-Host "No PowerShell files changed in this PR" - exit 0 - } - - Write-Host "Found $($changedFiles.Count) changed PowerShell file(s)" - - foreach ($file in $changedFiles) { - if (Test-Path $file) { - Write-Host "Analyzing: $file" - $analysis = Invoke-ScriptAnalyzer -Path $file -Severity Error,Warning - if ($analysis) { - $results += $analysis - foreach ($result in $analysis) { - $fileName = Split-Path $file -Leaf - Write-Host "::error file=$fileName,line=$($result.Line),col=$($result.Column)::$($result.Message)" - } - } - } - } - - if ($results.Count -gt 0) { - Write-Host "`n$($results.Count) issue(s) found" - exit 1 - } else { - Write-Host "`nNo issues found" - }