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
( 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.
|
foreach ($jFilter in $JobFilter) { |
|
if ($jFilter -match '`*') { |
|
if ($Not) { |
|
$job | Where-Object Name -NotLike $jFilter |
|
} else { |
|
$job | Where-Object Name -Like $jFilter |
|
} |
|
} else { |
|
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.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
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
-eqor-neinstead of-likeor-notlike. There is also the issue of jobs with an asterisk in their name.Steps to Reproduce
Please confirm that you are running the most recent version of dbatools
( Version not as relevant as this issue exists in the latest commit on the
developmentbranch as of this message )Other details or mentions
Consider the below class and method instead.
Use in the below code paths for
$jFilterand$sFilter.dbatools/private/functions/Get-JobList.ps1
Lines 74 to 81 in 6b53882
dbatools/private/functions/Get-JobList.ps1
Lines 89 to 96 in 6b53882
What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe)
PowerShell Host Version
SQL Server Edition and Build number
.NET Framework Version