Wednesday, February 19, 2014

Memory management with Start-SPAssignment

I was just playing around with some PowerShell and thought of writing a post on Start-SPAssignment cmdlet. This cmdlet is very useful if you work with memory intensive object as SPSite, SPWeb or SPSiteAdminstration. The default procedure is, with the use of a Get cmdlet it will automatically dispose these objects immediately and release the memory after the pipeline finishes.
But with Start-Assignment you can assign the list of objects to a variable or a global assignment store and dispose when no longer needed.

There are three assignment levels.

  • No assignment  - where the object is not assigned to a object and is disposed after each iteration of the command.
  • Simple assignment - This is done by using the global parameter. All objects are assigned to a global assignment store and released by calling the Stop-SPAssignment cmdlet.
  • Advanced assignment - Objects are assigned to a named store and released by using the StopAssignment with -identity parameter. 


Technet Samples


No comments: