dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

`Get-JobList` Filter Non-asterisk Wildcard Character Handling

Open mattcargile opened this issue 8 months ago • 19 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

If users, use any other wildcard character aside from asterisk, there will be unexpected behavior and the pattern matching will switch to -eq or -ne instead of -like or -notlike. There is also the issue of jobs with an asterisk in their name.

Steps to Reproduce

$sqli = 'sqli'
New-DbaAgentJob -SqlInstance  $sqli -Job 'Filter'
Find-DbaAgentJob -SqlInstance $sqli -JobName filte?

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

2.1.28 

( Version not as relevant as this issue exists in the latest commit on the development branch as of this message )

Other details or mentions

Consider the below class and method instead.

[WildcardPattern]::ContainsWildcardCharacters( 'hi`?')

Use in the below code paths for $jFilter and $sFilter. https://github.com/dataplat/dbatools/blob/6b5388255ce3fcc8d74c723bd8f9abfe62742646/private/functions/Get-JobList.ps1#L74-L81 https://github.com/dataplat/dbatools/blob/6b5388255ce3fcc8d74c723bd8f9abfe62742646/private/functions/Get-JobList.ps1#L89-L96

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.22631
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

Microsoft SQL Server 2017 (RTM-CU20) (KB4541283) - 14.0.3294.2 (X64) 
	Mar 13 2020 14:53:45 
	Copyright (C) 2017 Microsoft Corporation
	Standard Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: ) (Hypervisor)

.NET Framework Version

.NET 9.0.1

mattcargile avatar Feb 24 '25 15:02 mattcargile