Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EntraAuth/EntraAuth.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'EntraAuth.psm1'

# Version number of this module.
ModuleVersion = '1.8.52'
ModuleVersion = '1.8.54'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
5 changes: 5 additions & 0 deletions EntraAuth/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.8.54 (2026-06-06)

+ New: Service for connecting to the Log Analytics Api
+ Upd: Invoke-EntraRequest - added integrated support for delta request

## 1.8.52 (2026-02-20)

+ Fix: Connect-EntraService - Federated Credentials fail to refresh the token correctly
Expand Down
43 changes: 41 additions & 2 deletions EntraAuth/functions/Core/Invoke-EntraRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,30 @@

.PARAMETER Raw
Do not process the response object and instead return the raw result returned by the API.

.PARAMETER DeltaSession
A hashtable including delta sessions.
Use together with the delta endpoints, e.g. for the Graph API's user delta endpoint:
https://learn.microsoft.com/en-us/graph/api/user-delta
Provide an empty hashtable on the first request, the delta token data will be inserted into it.
Provide the same token for subsequent delta requests.

This allows retrieving changes over time, without having to reload the entire dataset.

.PARAMETER MinimalDelta
When receiving delta data, only return the changed properties (plus a unique identifier), rather than the full object.
Only used together with DeltaSession

.EXAMPLE
PS C:\> Invoke-EntraRequest -Path 'alerts' -RequiredScopes 'Alert.Read'

Return a list of defender alerts.

.EXAMPLE
PS C:\> Invoke-EntraRequest -Path 'users/delta' -DeltaSession $delta

Retrieves all users on first request.
Subsequent calls will only return users that have been changed in the meantime.
#>
[CmdletBinding(DefaultParameterSetName = 'default')]
param (
Expand Down Expand Up @@ -98,7 +117,13 @@
$NoPaging,

[switch]
$Raw
$Raw,

[hashtable]
$DeltaSession,

[switch]
$MinimalDelta
)

DynamicParam {
Expand Down Expand Up @@ -143,6 +168,7 @@
Method = $Method
Uri = Resolve-RequestUri -TokenObject $tokenObject -ServiceObject $serviceObject -BoundParameters $PSBoundParameters
}
$originalUri = $parameters.Uri

if ($PSBoundParameters.Keys -contains 'Body') {
if ($Body -is [string]) {
Expand All @@ -158,11 +184,16 @@
$parameters.Remove('Body')
}

$parameters.Uri += ConvertTo-QueryString -QueryHash $Query -DefaultQuery $tokenObject.Query
$queryClone = $Query.Clone()
if ($DeltaSession -and $DeltaSession[$originalUri].Token) {
$queryClone['$deltaToken'] = $DeltaSession[$originalUri].Token
}
$parameters.Uri += ConvertTo-QueryString -QueryHash $queryClone -DefaultQuery $tokenObject.Query

do {
$tempHeader = $tokenObject.GetHeader().Clone() # GetHeader() automatically refreshes expired tokens
foreach ($pair in $Header.GetEnumerator()) { $tempHeader[$pair.Key] = $pair.Value }
if ($MinimalDelta) { $tempHeader['Prefer'] = 'return=minimal' }
$parameters.Headers = $tempHeader
Write-Verbose "Executing Request: $($Method) -> $($parameters.Uri)"
try { $result = Invoke-RestMethod @parameters -ErrorAction Stop }
Expand Down Expand Up @@ -195,6 +226,14 @@
if (-not $Raw -and -not $tokenObject.RawOnly -and $result.PSObject.Properties.Where{ $_.Name -eq 'value' }) { $result.Value }
else { $result }
$parameters.Uri = $result.'@odata.nextLink'

if ($DeltaSession -and $result.'@odata.deltaLink') {
$deltaToken = (($result.'@odata.deltaLink' -split '\?')[1] -split '=')[-1]
if (-not $DeltaSession[$originalUri]) {
$DeltaSession[$originalUri] = @{}
}
$DeltaSession[$originalUri]['Token'] = $deltaToken
}
}
while ($parameters.Uri -and -not $NoPaging)
}
Expand Down
Loading