-
-
Notifications
You must be signed in to change notification settings - Fork 863
Get-JobList Filter Non-asterisk Wildcard Character Handling #9600
Copy link
Copy link
Open
Labels
Description
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.
dbatools/private/functions/Get-JobList.ps1
Lines 74 to 81 in 6b53882
| foreach ($jFilter in $JobFilter) { | |
| if ($jFilter -match '`*') { | |
| if ($Not) { | |
| $job | Where-Object Name -NotLike $jFilter | |
| } else { | |
| $job | Where-Object Name -Like $jFilter | |
| } | |
| } else { |
dbatools/private/functions/Get-JobList.ps1
Lines 89 to 96 in 6b53882
| foreach ($sFilter in $StepFilter) { | |
| if ($sFilter -match '`*') { | |
| if ($Not) { | |
| $stepFound = $job.JobSteps | Where-Object Name -NotLike $sFilter | |
| if ($stepFound.Count -gt 0) { | |
| $job | |
| } | |
| } else { |
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.0SQL 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.1Reactions are currently unavailable