Forum Discussion
Jussi Palo
Feb 15, 2017Iron Contributor
Office PnP PowerShell: How to dispose SPWeb from Get-PnPSubWebs
Having foreach loop with Get-PnPSubWebs, how do I dispose SPWebs at the end of loop cycle?
3 Replies
- DeletedI think this thread will help you http://stackoverflow.com/questions/1999858/how-bad-is-it-to-not-dispose-in-powershell
- I may not understand your question correctly. Dispose is available only through Context. You can post the sample to provide you the proper feedback.
- Jussi PaloIron Contributor
So like this?
foreach ($web in Get-PnPSubWebs) { #Do something with $web $web.Context.Dispose() # <<<<< }