-
-
Notifications
You must be signed in to change notification settings - Fork 863
Get-DbaDbOrphanUser contained availability group #9789
Description
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.

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_msdbPlease 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