Skip to content

Commit

Permalink
return hidden from GAL property too
Browse files Browse the repository at this point in the history
  • Loading branch information
kris6673 committed Feb 4, 2025
1 parent d3a5cbf commit b03bd61
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Modules/CIPPCore/Public/Entrypoints/Invoke-ListContacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ Function Invoke-ListContacts {
$TenantFilter = $Request.Query.tenantFilter
$ContactID = $Request.Query.id

# Write-Host "Tenant Filter: $TenantFilter"
# Write-Host "Contact ID: $ContactID"

# Validate required parameters
if (-not $TenantFilter) {
$StatusCode = [HttpStatusCode]::BadRequest
Expand All @@ -47,18 +44,18 @@ Function Invoke-ListContacts {
"https://graph.microsoft.com/beta/contacts?`$top=999&`$select=$($selectList -join ',')"
}

# Write-Host "Making Graph API request to: $graphUri"

# Make the Graph API request
$GraphRequest = New-GraphGetRequest -uri $graphUri -tenantid $TenantFilter

if ([string]::IsNullOrWhiteSpace($ContactID) -eq $false) {
$HiddenFromGAL = New-EXORequest -tenantid $TenantFilter -cmdlet 'Get-Recipient' -cmdParams @{RecipientTypeDetails = 'MailContact' } -Select 'HiddenFromAddressListsEnabled,ExternalDirectoryObjectId' | Where-Object { $_.ExternalDirectoryObjectId -eq $ContactID }
$GraphRequest | Add-Member -NotePropertyName 'hidefromGAL' -NotePropertyValue $HiddenFromGAL.HiddenFromAddressListsEnabled
}
# Ensure single result when ID is provided
if ($ContactID -and $GraphRequest -is [array]) {
$GraphRequest = $GraphRequest | Select-Object -First 1
}

$StatusCode = [HttpStatusCode]::OK
# Write-Host (ConvertTo-Json $GraphRequest -Depth 5)
} catch {
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
$StatusCode = [HttpStatusCode]::InternalServerError
Expand Down

0 comments on commit b03bd61

Please sign in to comment.