Description
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Remove-DbaDbOrphanUser fails on Database Snapshots. Think $DatabaseCollection should only include database that are updatable. Either filter on the IsDatabaseSnapshote, IsUpdateable or ReadOnly property on line 121
Steps to Reproduce
# provide your command(s) executed pertaining to dbatools
# please include variable values (redacted or fake if needed) for reference
Create a test database
Create a SQL login and database user
Delete the login
Create a database snapshot of the new database.
$instance = "localhost"
Remove-DbaDbOrphanUser -SqlInstance $instance;
Please confirm that you are running the most recent version of dbatools
1.1.143
Other details or mentions
No response
What PowerShell host was used when producing this error
VS Code (integrated terminal)
PowerShell Host Version
Name Value
PSVersion 5.1.22000.3260
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.3260
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-CU19) (KB5054531) - 16.0.4195.2 (X64) Apr 18 2025 13:42:14 Copyright (C) 2022 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2022 Standard 10.0
.NET Framework Version
.NET Framework 4.8.9277.0