resourcemanagement-powershell icon indicating copy to clipboard operation
resourcemanagement-powershell copied to clipboard

Deleting all objects results halfway (6.000) in a paging error

Open Ruffio opened this issue 6 years ago • 8 comments

Hi.

I'm using Powershell to remove all objects as per: https://github.com/lithnet/resourcemanagement-powershell/wiki/Remove-Resource

I got about 6.000 objects removed, then I got the error about paging. It is not really an issue for me as I just started the script again and then I will get the rest of the objects removed, but I just wanted to let you guys know.

If this is working as expected, then maybe a note on the above page would be a good idea? Just a suggestion. I have searched the Wiki for paging but didn't get any results.

lithnet remove fails

Ruffio avatar Jun 28 '18 09:06 Ruffio

Have you tried to use the "Search-ResourcesPaged" command? By using this, you can bulk delete objects instead of deleting one object at a time:

image

FredrikMelby avatar Jun 28 '18 09:06 FredrikMelby

No, I didn't think of that. I just followed the wiki and used what was described there. Maybe it should be updated with a note about the above? I mean, when there is an example about deleting all the objects in one/two line, I expect what is described there to be the most optimal way.

Btw. my script just failed again after 3.000 entries. Can I expect to get the paging error for every time, I'm half way?

Ruffio avatar Jun 28 '18 10:06 Ruffio

Hmmm, and it failed again at 1.500 :-( So I was right about it is failing every time I get halfway.

I will use the above bulk method, but I really think, that there is an issue here...

Ruffio avatar Jun 28 '18 10:06 Ruffio

And failed again when having 600 left out of 1.500. If there is a limit when removing objects, it should be noted in the wiki

Ruffio avatar Jun 28 '18 10:06 Ruffio

And failed again when getting to 200 out of 600

Ruffio avatar Jun 28 '18 10:06 Ruffio

I have seen this behaviour in rare cases using the paged search cmdlet (against several thousand objects), but never as consistent as you describe here. Them I have also ended up running my scripts again when this has occured - but it's usually finishes ok the second time.

FredrikMelby avatar Jun 28 '18 10:06 FredrikMelby

The last 200 objects has now been removed by the last attempt. If this is expected behavior I'm willing to close this issue. However I think there should be a note about it or at least that one should consider to use the paged search approach, if that is better, but reading the above comment suggests that approach also can fail.

Ruffio avatar Jun 28 '18 10:06 Ruffio

That's a bug.

I'll also update the guidance for deleting large numbers of objects. The examples shown aren't the most efficient for very large datasets, @FredrikMelby example is the correct way.

ryannewington avatar Jun 28 '18 11:06 ryannewington