-
-
Notifications
You must be signed in to change notification settings - Fork 841
Description
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
The documentation states that these parameters accept wildcards but do not state what the wildcards are such as % or *. I tried all permutations that I could think of, tried to find examples, and then went to the source code. It appears that these are not set to accept wildcards.
Parameter Definitions
.PARAMETER Database
Specifies one or more databases to include in the results. Supports wildcards and exact name matching.
Use this when you need to retrieve specific databases instead of all databases on the instance.
.PARAMETER ExcludeDatabase
Specifies one or more databases to exclude from the results. Supports wildcards and exact name matching.
Use this to filter out specific databases like test or staging environments from your inventory.
However, the source code shows the following pattern:
Where-Object {
($_.name -in $Database -or !$Database) -and
($_.name -notin $ExcludeDatabase -or !$ExcludeDatabase) -and
($_.Owner -in $Owner -or !$Owner) -and
($_.state -ne 6 -or !$OnlyAccessible)
}
This would allow an array of exact match database names or having no database names passed in from what I can tell. It does not appear that you can pass any type of wildcard partial matches.
Steps to Reproduce
With Database names such as dbatools_example1, dbatools_example2, dbatools_example3, dbatools_example4, dbatools_example5 the following commands will not return any results
PS C:\> Get-DbaDatabase -SqlInstance SQL2,SQL3 -Database dbatools_example
PS C:\> Get-DbaDatabase -SqlInstance SQL2,SQL3 -Database dbatools_example*
PS C:\> Get-DbaDatabase -SqlInstance SQL2,SQL3 -Database dbatools_example%
Please confirm that you are running the most recent version of dbatools
I checked the most recent source code from here for verification:
https://github.com/dataplat/dbatools/blob/development/public/Get-DbaDatabase.ps1
PS > find-psresource dbatools
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
dbatools 2.7.2 PSGallery The community module that enables SQL Server Pros to automate database develop…
PS > get-psresource dbatools
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
dbatools 2.7.2 PSGallery The community module that enables SQL Server Pros to automate database develop…
Other details or mentions
No response
What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe)
PowerShell Host Version
PS > $psversiontable
Name Value
---- -----
PSVersion 7.5.2
PSEdition Core
GitCommitId 7.5.2
OS Microsoft Windows 10.0.26120
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SQL Server Edition and Build number
SQL Server 2022 Build 16.0.4210.1
Issue is version agnostic
.NET Framework Version
PS > [System.Runtime.InteropServices.RuntimeInformation]::get_FrameworkDescription()
.NET 9.0.6
PS > Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name version -EA 0 | Where PSChildName -Match '^(?!S)\p{L}' | Select PSChildName, 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.09032
Full 4.8.09032
Client 4.0.0.0