Skip to content

Get-DbaDbOrphanUser contained availability group #9789

@Gincules

Description

@Gincules

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

Server principals ##MS_PolicyEventProcessingLogin## and ##MS_PolicyTsqlExecutionLogin## in contained always on group databases master and msdb returned as orphan user.


Image


With contained AGs, each AG has its own independent set of system databases (master, msdb) that live inside the availability group. Each contained system database (master, msdb) inside the AG creates its own instance of these special logins with different sids. This means dbatools result is incorrect.

Steps to Reproduce

Get-DbaDbOrphanUser -SqlInstance localhost -Database contained_ag_db_master
Get-DbaDbOrphanUser -SqlInstance localhost -Database contained_ag_db_msdb

Please confirm that you are running the most recent version of dbatools

Major Minor Build Revision


2 5 5 -1

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.20348.3932

PSEdition Desktop

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}

BuildVersion 10.0.20348.3932

CLRVersion 4.0.30319.42000

WSManStackVersion 3.0

PSRemotingProtocolVersion 2.3

SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2022 (RTM-CU20-GDR) (KB 5063814) - 16.0.4210.1 (X64)
Microsoft SQL Server 2025 (CTP2.1) - 17.0.800.3 (X64)

.NET Framework Version

PSChildName Version


v2.0.50727 2.0.50727.4927

v3.0 3.0.30729.4926

Windows Communication Foundation 3.0.4506.4926

Windows Presentation Foundation 3.0.6920.4902

v3.5 3.5.30729.4926

Client 4.8.04161

Full 4.8.04161

Client 4.0.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions