Skip to content

Commit 251eaec

Browse files
committed
Update search parameters
The CaseSensitive parameter was removed and replaced with MatchAll, which requires all search terms to be found when specified. The default behavior now matches any term. Documentation and logic were updated accordingly.
1 parent 0b7d604 commit 251eaec

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Modules/CIPPCore/Public/Search-CIPPDbData.ps1

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function Search-CIPPDbData {
2121
Groups, Roles, LicenseOverview, IntuneDeviceCompliancePolicies, SecureScore,
2222
SecureScoreControlProfiles, Mailboxes, CASMailbox, MailboxPermissions, OneDriveUsage, MailboxUsage
2323
24-
.PARAMETER CaseSensitive
25-
If specified, performs case-sensitive search
24+
.PARAMETER MatchAll
25+
If specified, all search terms must be found. Default is false (any term matches).
2626
2727
.PARAMETER MaxResultsPerType
2828
Maximum number of results to return per type. Default is unlimited (0)
@@ -60,7 +60,7 @@ function Search-CIPPDbData {
6060
[string[]]$Types,
6161

6262
[Parameter(Mandatory = $false)]
63-
[switch]$CaseSensitive,
63+
[switch]$MatchAll,
6464

6565
[Parameter(Mandatory = $false)]
6666
[int]$MaxResultsPerType = 0
@@ -112,16 +112,20 @@ function Search-CIPPDbData {
112112
# Check if any search term matches in the JSON string
113113
$IsMatch = $false
114114

115-
foreach ($SearchTerm in $SearchTerms) {
116-
# Use -match operator with escaped search term
117-
$SearchPattern = [regex]::Escape($SearchTerm)
118-
119-
if ($CaseSensitive) {
120-
if ($Item.Data -cmatch $SearchPattern) {
121-
$IsMatch = $true
115+
if ($MatchAll) {
116+
# All terms must match
117+
$IsMatch = $true
118+
foreach ($SearchTerm in $SearchTerms) {
119+
$SearchPattern = [regex]::Escape($SearchTerm)
120+
if ($Item.Data -notmatch $SearchPattern) {
121+
$IsMatch = $false
122122
break
123123
}
124-
} else {
124+
}
125+
} else {
126+
# Any term can match (default)
127+
foreach ($SearchTerm in $SearchTerms) {
128+
$SearchPattern = [regex]::Escape($SearchTerm)
125129
if ($Item.Data -match $SearchPattern) {
126130
$IsMatch = $true
127131
break

0 commit comments

Comments
 (0)