Skip to content

Commit 87c4bb2

Browse files
authored
Merge pull request #766 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents c3d7e31 + 9aa02ea commit 87c4bb2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ListUserMailboxDetails.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ function Invoke-ListUserMailboxDetails {
155155
# First try users array
156156
$matchedUser = $usernames | Where-Object {
157157
$_.id -eq $rawAddress -or
158-
$_.displayName -eq $rawAddress -or
159158
$_.mailNickname -eq $rawAddress
160159
}
161160

@@ -166,7 +165,8 @@ function Invoke-ListUserMailboxDetails {
166165
try {
167166
# Escape single quotes in the filter value
168167
$escapedAddress = $rawAddress -replace "'", "''"
169-
$filterQuery = "displayName eq '$escapedAddress' or mailNickname eq '$escapedAddress'"
168+
$escapedNickname = $rawAddress -replace "'", "''" -replace ' ', ''
169+
$filterQuery = "displayName eq '$escapedAddress' or mailNickname eq '$escapedNickname'"
170170
$contactUri = "https://graph.microsoft.com/beta/contacts?`$filter=$filterQuery&`$select=displayName,mail,mailNickname"
171171

172172
$matchedContacts = New-GraphGetRequest -tenantid $TenantFilter -uri $contactUri

Modules/CIPPCore/Public/New-CIPPCAPolicy.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ function New-CIPPCAPolicy {
9292
Remove-EmptyArrays -Object $JSONobj
9393
#Remove context as it does not belong in the payload.
9494
try {
95-
$JSONobj.grantControls.PSObject.Properties.Remove('[email protected]')
95+
if ($JSONobj.grantControls) {
96+
$JSONobj.grantControls.PSObject.Properties.Remove('[email protected]')
97+
}
9698
$JSONobj.templateId ? $JSONobj.PSObject.Properties.Remove('templateId') : $null
9799
if ($JSONobj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.Members) {
98100
$JSONobj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.PSObject.Properties.Remove('@odata.context')
@@ -426,7 +428,7 @@ function New-CIPPCAPolicy {
426428
# Preserve any exclusion groups named "Vacation Exclusion - <PolicyDisplayName>" from existing policy
427429
try {
428430
$ExistingVacationGroup = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/groups?`$filter=startsWith(displayName,'Vacation Exclusion')&`$select=id,displayName&`$top=999&`$count=true" -ComplexFilter -tenantid $TenantFilter -asApp $true |
429-
Where-Object { $CheckExisting.conditions.users.excludeGroups -contains $_.id }
431+
Where-Object { $CheckExisting.conditions.users.excludeGroups -contains $_.id }
430432
if ($ExistingVacationGroup) {
431433
if (-not ($JSONobj.conditions.users.PSObject.Properties.Name -contains 'excludeGroups')) {
432434
$JSONobj.conditions.users | Add-Member -NotePropertyName 'excludeGroups' -NotePropertyValue @() -Force

0 commit comments

Comments
 (0)