msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Access delta link from delta cmdlets
Customers can use the delta commands to list all changes on a resource from start to finish and the nextLink will be followed to the end as stated at Use delta query to track changes in Microsoft Graph data - Microsoft Graph | Microsoft Learn.
However, today there is no way to access the deltaLink, that's returned on the last page to track changes from "last delta call".
I want to be able to access the deltaLink as well as passing it to the delta command, so I can track the changes from the last call.
@peombwa @timayabi2020 can you validate whether AutoREST supports it?
~The CSDL will also need to be annotated to signal to SDKs that delta functions support deltaToken query parameter - https://github.com/microsoftgraph/msgraph-metadata/issues/354.~
Per the discussion at https://github.com/microsoftgraph/msgraph-metadata/issues/354#issuecomment-1644373358, the SDK should instead add support -DeltaLink parameter, which takes the @odata.deltalink value from the previous call:
Get-Mg*Delta -DeltaLink $link # value from the odata.deltalink property of the previous call
The implementation should ensure:
@odata.deltalinkproperty from the previous request is available to the caller. This can be a global variable, etc.Get-Mg*Delta -DeltaLinkparameter set should only support-DeltaLinkparameter to avoid sending malformed request URIs. Query parameters are specified once in the initial request. Microsoft Graph automatically encodes the specified parameter into the@odata.deltaLinkreturned in the response.
Hey folks, just adding my 2c - been talking over this with @SteveMutungi254 since May and then it got kinda forgotten for a while, as I mistakenly popped the bug in ADO and not here :) Got a bit of flak from customers on this as they were building automation around the delta functionality. Given them this sample as a workaround, but certainly seems an overlooked capability ;)
@CarolKigoonya
Copying from ADO
Solution options
- Implement session/module variable to cache deltaLink, and implicitly use it on subsequent Get-MgXxxxDelta executions. Downside - only persistent within session, so not suitable for scheduled jobs (based on customer conversations, this is mostly used in non-interactive automation).
- Add explicit -DeltaLinkVariable parameter to push the link into current scope so user can handle the saving/retrieval themselves, and explicit -DeltaLink parameter to use the link in subsequent calls.
(ideally - both options to give users flexibility) Instead of full deltaLink, can save just the deltaToken (marginally reduces memory/storage use, but makes it harder to reuse the link elsewhere.
I just want to share that this is also impacting me, and is another case of the Graph SDK's lack of "fit and finish." I will attempt to use the workaround provided here, thank you, or just use Invoke-MgGraphRequest. Thanks
any progress on this issue?
Hey folks, just adding my 2c - been talking over this with @SteveMutungi254 since May and then it got kinda forgotten for a while, as I mistakenly popped the bug in ADO and not here :) Got a bit of flak from customers on this as they were building automation around the delta functionality. Given them this sample as a workaround, but certainly seems an overlooked capability ;)
@CarolKigoonya
How do you get the removed users with this sample? In my case it returns 380 users. The actual membership is 376 with 4 removed (1 object was deleted)
Using Get-MgGroupDelta objects that have been removed have an @removed key
@odata.type
id
@removed
I don't see that when using the workaround sample. When using Invoke-MgGraphRequest and setting OutputType to PSObject that key is not included.
$groupDelta.value.'members@delta' | Get-member | select name
Name
Equals
GetHashCode
GetType
ToString
@odata.type
id
any ETA on this issue?