Skip to content

New-DbaDbUser doesn't respect -Database param for system dbs #8888

Closed
@lowlydba

Description

Verified issue does not already exist?

Yes

What error did you receive?

When creating a user in a system database, the function claims that specifying a Database will override the default mode of excluding system databases, but it does not.

The param description:

.PARAMETER IncludeSystem
If this switch is enabled, the user will be added to system databases. This switch will be ignored if -Database is used.

The logic:

if ($Database) { $getDbParam.Database = $Database }
if ($ExcludeDatabase) { $getDbParam.ExcludeDatabase = $ExcludeDatabase }
if (-not ($IncludeSystem)) { $getDbParam.ExcludeSystem = $True }

Steps to Reproduce

# No change
New-DbaDbUser -SqlInstance localhost -Database master -User lowlydba2 -Login lowlydba -DefaultSChema "Information_SCHEMA" -Verbose 
# Works
New-DbaDbUser -SqlInstance localhost -Database master -User lowlydba2 -Login lowlydba -DefaultSChema "Information_SCHEMA" -Verbose -IncludeSystem

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

v2.0.0 (congrats!)

Other details or mentions

No response

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

N/A

SQL Server Edition and Build number

N/A

.NET Framework Version

N/A

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