Alexander Anikin's blog

My personal blog

Sharepoint 2010, Powershell and object dispose

with one comment

Source article: http://stsadm.blogspot.com/2009/10/sharepoint-2010-stsadm-and-powershell.html

Extraction about disposing object in Powershell for Sahrepoint:

If you’re going to be working with the SharePoint PowerShell cmdlets then there are two cmdlets that you should learn before any others: Start-SPAssignment and Stop-SPAssignment. If you’ve used the custom cmdlets that I created for the 2007 product and read my articles around them then you should be familiar with the core issue that I was trying to solve with some of them – the handling of disposable objects.

#Use of the Global assignment variable

Start-SPAssignment –Global

$site = Get-SPSite http://portal

$site | fl Stop-SPAssignment –Global

#Use of a semi-global, or named variable

 $gc = Start-SPAssignment

$site = $gc | Get-SPSite http://mysites

$site | fl

$gc | Stop-SPAssignment

Advertisements

Written by Alex Anikin

October 5, 2010 at 11:33 am

Posted in Sharepoint

One Response

Subscribe to comments with RSS.

  1. Great weblog! I truly enjoy the way it? s easy on my eyes as well as the Information are nicely written. I’m questioning how i could be notified every time a brand new post continues to be produced. I have subscribed to your rss feed which need to try and do the trick! Have a great day!

    generika cialis

    December 3, 2010 at 5:34 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: