Add PSScriptAnalyzer CI validation for all PowerShell scripts#9
Merged
Merged
Conversation
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Validate all PowerShell scripts in CI
Add PSScriptAnalyzer CI validation for all PowerShell scripts
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All 20
.ps1files in the repo lacked any automated linting or static analysis in CI. Only the git-hooks Pester tests ran, leavingProfile.ps1,install.ps1, and allbucket/scripts unchecked.Changes
PSScriptAnalyzerSettings.psd1— Repo-root settings file with 13 curated rule exclusions tuned for personal config/utility scripts (standalone hooks and profiles, not exported module cmdlets). Each exclusion is justified inline, e.g.:PSAvoidUsingInvokeExpression— standard Chocolatey bootstrap andoh-my-posh initpatternsPSUseApprovedVerbs/PSUseSingularNouns— private helper functions, not public cmdletsPSAvoidUsingEmptyCatchBlock— intentional resilience inProfile.ps1(TLS setup, mutex cleanup).github/workflows/validate-powershell.yml— New workflow that runsInvoke-ScriptAnalyzer -Recurseagainst the entire repo on any.ps1, settings file, or workflow file change. Fails fast on any finding. Complementstest-git-hooks.yml(Pester) without duplicating it.The settings baseline is green on the current codebase; future PRs touching any
.ps1file will be gated against this check.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.