microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
693 stars 166 forks source link

Access delta link from delta cmdlets #2062

Open maisarissi opened 1 year ago

maisarissi commented 1 year ago

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.

maisarissi commented 1 year ago

@peombwa @timayabi2020 can you validate whether AutoREST supports it?

peombwa commented 1 year ago

~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.~

peombwa commented 1 year ago

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:

pgarm commented 1 year ago

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

pgarm commented 1 year ago

Copying from ADO

Solution options

  1. 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).
  2. 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.

jreinhardtproarch commented 10 months ago

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

Jakke2440 commented 6 months ago

any progress on this issue?

timmgreen commented 5 months ago

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

MartinM85 commented 2 months ago

any ETA on this issue?