Skip to content

New-DbaFirewallRule - Fix binary path extraction and remove dead code#10294

Merged
potatoqualitee merged 1 commit into
developmentfrom
claude/issue-9229-20260331-0620
Apr 3, 2026
Merged

New-DbaFirewallRule - Fix binary path extraction and remove dead code#10294
potatoqualitee merged 1 commit into
developmentfrom
claude/issue-9229-20260331-0620

Conversation

@andreasjordan
Copy link
Copy Markdown
Collaborator

Fixes two bugs in the executable-based firewall rule implementation added for issue #9229.

Changes

  • Fix unsafe -replace for binary path extraction: PowerShell's -replace returns the original string unchanged when the pattern doesn't match. If BinaryPath didn't contain sqlservr.exe/sqlbrowser.exe, the original path value would silently be used as the firewall rule's Programpath. Changed to-match+$Matches[1]` which only sets the path when the regex actually matched.
  • Remove dead $programNeeded variable: Was set in two places but never read — actual logic relied on checking $rule.Config.Program directly.

Closes #9229

Generated with Claude Code

- Replace unsafe -replace regex (returns original string on no match, so a
  non-matching BinaryPath would silently produce a wrong Program path) with
  -match + $Matches[1] for both sqlservr.exe and sqlbrowser.exe detection
- Remove unused \$programNeeded variable (was set but never read)

(do New-DbaFirewallRule)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@potatoqualitee potatoqualitee merged commit 1fdfdde into development Apr 3, 2026
15 checks passed
@potatoqualitee potatoqualitee deleted the claude/issue-9229-20260331-0620 branch April 3, 2026 18:35
potatoqualitee added a commit that referenced this pull request Apr 10, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update New-DBAFirewallRule to target the executables instead of TCP/UDP port

2 participants