Powershell hangs on Get-PnPListItem foreach

%3CLINGO-SUB%20id%3D%22lingo-sub-2189718%22%20slang%3D%22en-US%22%3EPowershell%20hangs%20on%20Get-PnPListItem%20foreach%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2189718%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3CBR%20%2F%3EI%20am%20trying%20to%20get%20a%20list%20of%20largest%20files%20or%20files%20with%20too%20many%20versions%2C%20so%20I%20am%20using%20%24list%20%3D%20Get-PnPListItem%20%2C%20but%20it%20hangs%20on%20foreach(%24item%20in%20%24list)%20as%20the%20folder%20has%20about%20300000%20items.%3CBR%20%2F%3ESo%20is%20there%20any%20way%20to%20overcome%20this%20issue%20(do%20it%20in%20chunks%20etc)%3F%3CBR%20%2F%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2189718%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

Hi All
I am trying to get a list of largest files or files with too many versions, so I am using $list = Get-PnPListItem , but it hangs on foreach($item in $list) as the folder has about 300000 items.
So is there any way to overcome this issue (do it in chunks etc)?
Thanks

0 Replies