Skip to content

Get-JobList -JobFilter Doesn't Handle Multiple Wildcarded Items Correctly  #9572

Closed
@mattcargile

Description

@mattcargile

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

No Error. Usage like Find-DbaAgentJob -JobName filter*, filter2* does not return any items unless your Agent Jobs have the asterisks in their name. This impacts cmdlets like Find-DbaAgentJob.

Steps to Reproduce

$sqli = 'sqli'
New-DbaAgentJob -SqlInstance  $sqli -Job 'FilteredJob'
Find-DbaAgentJob -SqlInstance $sqli -JobName filter*,filter2*

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

2.1.26

Other details or mentions

Latest development branch shows this issue.

if ($JobFilter.Count -gt 1) {
if ($Not) {
$jobs | Where-Object Name -NotIn $JobFilter
} else {
$jobs | Where-Object Name -In $JobFilter
}

A loop would be required or a piped -like to handle multi-wildcards.

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      7.4.6
PSEdition                      Core
GitCommitId                    7.4.6
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 8.0.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmedLabel to be used by maintainers that confirm a bug does exist for the given issuetriage requiredNew issue that has not been reviewed by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions