Skip to content

Remove-DbaAgListener - Honor the AvailabilityGroup filter - #10609

Open
andreasjordan wants to merge 2 commits into
developmentfrom
fix-removedbaaglistener-availabilitygroup
Open

Remove-DbaAgListener - Honor the AvailabilityGroup filter#10609
andreasjordan wants to merge 2 commits into
developmentfrom
fix-removedbaaglistener-availabilitygroup

Conversation

@andreasjordan

@andreasjordan andreasjordan commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

Remove-DbaAgListener declares and documents -AvailabilityGroup ("Filters listener removal to only those within the specified availability groups") but never uses it. The internal Get-DbaAgListener call only received -Listener, so a removal scoped to one availability group removed the named listener regardless of which availability group it belonged to.

What changed

The -AvailabilityGroup parameter is now passed through to Get-DbaAgListener, which already supported it. The call was converted to a splat per the style guide.

A follow-up commit also corrects the -SqlInstance validation message, which demanded "one or more Availability Groups" although the check only requires -Listener.

What deliberately did not change

The pipeline path (-InputObject) is untouched: piped listener objects are already the caller's explicit selection.

Tests

Added a regression test that creates a second availability group, scopes the removal of the first group's listener to that second group, and asserts nothing is returned and the listener survives. Verified against the lab HADR instance (SQL Server 2025): the new test fails on the old code with exactly the reported behavior (Status=Removed for the out-of-scope listener) and the full file passes with the fix (3/3).

Same defect shape as #10608. Found by @greenmtnsun via static analysis, reported in #10607.

🤖 Generated with Claude Code

…Listener

The parameter was declared and documented but never used, so a removal
scoped to one availability group removed the named listener from
whatever availability group it belonged to. The regression test scopes
a removal to a second availability group and asserts the listener of
the first one survives.

Found via static analysis by @greenmtnsun in #10607.

(do Remove-DbaAgListener)
…oes not require

The error text told the user to specify one or more availability
groups, but the condition only ever required -Listener. The
AvailabilityGroup parameter is an optional filter.

(do Remove-DbaAgListener)
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.

1 participant