Skip to content

Commit c7e0452

Browse files
committed
Fix PSScriptAnalyzer: Use settings file instead of attributes
- Removed SuppressMessageAttribute from script (caused parse error) - Created .psscriptanalyzer.psd1 settings file to exclude rules - This is the proper way to configure PSScriptAnalyzer for scripts - Fixes 'Unexpected attribute' parse error in GitHub Actions
1 parent 018d8b0 commit c7e0452

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@{
2+
# Exclude specific rules for this script
3+
ExcludeRules = @(
4+
'PSAvoidUsingWriteHost', # Write-Host is needed for interactive prompts
5+
'PSUseApprovedVerbs', # Process-Folder is an internal helper function
6+
'PSAvoidOverwritingBuiltInCmdlets' # Write-Log is a common pattern
7+
)
8+
}
9+

file-server-audit/FolderAclAudit.ps1

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# PSScriptAnalyzer suppressions for interactive script requirements
2-
# Suppress PSAvoidUsingWriteHost - Write-Host is needed for interactive prompts and colored output
3-
# Suppress PSUseApprovedVerbs - Process-Folder is an internal helper function
4-
# Suppress PSAvoidOverwritingBuiltInCmdlets - Write-Log is a common pattern and our implementation is appropriate
5-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification='Write-Host is required for interactive prompts and colored output in this user-facing script')]
6-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs', '', Justification='Process-Folder is an internal helper function with clear naming')]
7-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidOverwritingBuiltInCmdlets', '', Justification='Write-Log is a common pattern and our implementation is appropriate for this script')]
81
param(
92
[Parameter(Mandatory = $false,
103
HelpMessage = "Root path to audit (e.g. \\fileserver\\share or C:\\Data)")]
@@ -268,7 +261,6 @@ function Get-FolderDepth {
268261
}
269262

270263
# Helper: process a single folder (get ACL, emit rows)
271-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs', '', Justification='Process-Folder is an internal helper function')]
272264
function Process-Folder {
273265
param(
274266
[System.IO.DirectoryInfo]$Folder,

0 commit comments

Comments
 (0)