<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My SharePoint of View &#187; How to</title>
	<atom:link href="http://mysharepointofview.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysharepointofview.com</link>
	<description>Thoughs from the field in SharePoint land</description>
	<lastBuildDate>Tue, 07 Dec 2010 17:04:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>A word about moving site collections</title>
		<link>http://mysharepointofview.com/2010/12/a-word-about-moving-site-collections/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-word-about-moving-site-collections</link>
		<comments>http://mysharepointofview.com/2010/12/a-word-about-moving-site-collections/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 17:04:27 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Operation]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Restore]]></category>
		<category><![CDATA[Site Collection]]></category>
		<category><![CDATA[STSADM]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=935</guid>
		<description><![CDATA[When the size of your site collections is increasing you sometimes have to move site collections around to put them in new content databases. There are a couple of different ways to perform a site collection move and I will try to cover some of them and end with a quite simple script that can [...]]]></description>
			<content:encoded><![CDATA[<p>When the size of your site collections is increasing you sometimes have to move site collections around to put them in new content databases. There are a couple of different ways to perform a site collection move and I will try to cover some of them and end with a quite simple script that can make the work even easier.</p>
<p>So the first one out is the simple <a title="Backup" href="http://technet.microsoft.com/en-us/library/cc263441(office.12).aspx">backup</a>/<a title="Restore" href="http://technet.microsoft.com/en-us/library/cc262087(office.12).aspx">restore </a>stsadm operations. The problem with this is that when doing the restore it&#8217;s not possible to specify what database to restore it to. So to be able to do this you need to lock the other content databases except the one you want to add it to. This might not be possible and the you could use a maintenance farm.</p>
<p>A much better option is the <a href="http://technet.microsoft.com/en-us/library/cc262923(office.12).aspx">mergecontentdbs </a>stsadm operation that was introduced in SP1 of Microsoft Office SharePoint Server 2007 and allows 3 different options. The first option only analyse the situation and calculate the amount of site collections in the content database and their size. The second option is to move all sites in the specified source content database and move them to the specified destination content database. Our last option is to use an xml file containing the sites that we want to move as an input file to the command and the operation will only move the sites specified in that xml-file</p>
<p>The best thing with the last option is that we can use the <a href="http://technet.microsoft.com/en-us/library/cc262492(office.12).aspx">enumsites</a> operation to get an xml file of all sites for our a specific web application.</p>
<pre>Example: stsadm -o enumsites -url [webAppUrl] -showlocks &gt; "D:tempsites.xml"</pre>
<p>The only problem with the above is that if you have a large amount of site collection and a number of content databases you will need to modify the list and remove the site collections that should not be moved to another content database. Later in this post I will show you how this problem can easily be addressed using PowerShell</p>
<p>Before using the mergecontentdbs operation you should consider two things. The first one is that since the mergecontentdbs operation is using the Content Deployment API it&#8217;s not suitable for sites larger then 10 GB. The other is that if content is changed during the operation you will not only risk losing the content but it could also cause database corruption as described in this KB: <a href="http://support.microsoft.com/kb/969242">http://support.microsoft.com/kb/969242</a>. So before moving the sites it&#8217;s a good recommendation to lock the site collections before the move.</p>
<p>To solve this I created a PowerShell script that does the following:</p>
<ol>
<li>Exports all the site collection for specific web application to an xml-file</li>
<li>Remove all sites in the file that is not located in the database I have specified</li>
<li>Sets the site collections to no access to prevent data loss</li>
<li>Move the sites from the source database to the destination database using the xml file</li>
<li>Offers you to make an IISreset on all WFEs in the farm (Recommended after the stsadm operation)</li>
<li>Set the site collection lock back to it&#8217;s original</li>
</ol>
<pre>$env:PATH = $env:PATH +
";C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12BIN" 

$webAppUrl = "http://myWebAppUrl"
$sourceContentDB = "SourceContentDB"
$destinationContentDB = "DestinationContentDB"
$xmlfile = "d:tempsites.xml" 

# enumerate through all site collections and save them to the XML-file
Write-Host "Retreives all site collections located at"
$webAppUrl "and save it to " $xmlfile
stsadm -o enumsites -url $webAppUrl -showlocks &gt; $xmlfile | out-null 

# Import the XML file content $sites = [xml](Get-Content $xmlfile)
# Remove only the site collections located in the source database
Write-Host "Cleaning up the" $xmlfile "file and remove sites that should not be affected"
$sites.Sites.Site | Where-Object {$_.ContentDatabase -ne $sourceContentdb} |
ForEach-Object { $_.ParentNode.RemoveChild($_) | out-null } 

# Enumerate through all the sites in the xml file and make necessary preparations 

foreach($site in $sites.sites.site) {
# Lock the sites to prevent errors when migration and data loss
Write-Host "Locking the site" $site.url "to prevent data loss"
stsadm -o setsitelock -url $site.URL -lock Noaccess
} 

# Moving sites
stsadm -o mergecontentdbs -url $webAppUrl -sourcedatabasename $sourceContentDB
  -destinationdatabasename $destinationContentDB -operation 3 -filename $xmlfile 

# Get the farm object to find get all the WFEs in the farm
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
Write-Host "To complete the move you need to make an IISreset on all WFEs in the farm"
Write-Host "You will now get the option to make an IISreset on all your WFEs"
Write-Host "" 

# Enumerate through all servers in the farm 

foreach ($svr in $farm.Servers) {
  foreach ($svc in $svr.ServiceInstances) {
    # If the server has the Windows SharePoint Services Web Application service it
    # is most likely it's a WFE.
    if($svc.TypeName -eq "Windows SharePoint Services Web Application"){
      # Ask if we should make an IISReset on the server
      $IISReset = Read-Host "Do you want to make an IIS-reset on"
      $svr.DisplayName "server (yes/No)?"
      if($IISReset.ToLower() -eq "yes") {
        iisreset $svr.DisplayName
      }
    }
  }
}
# Enumerate through all the sites in the xml file and finalize the move
foreach($site in $sites.sites.site) {
  # Set the original lockstate for the site collection
  Write-Host "Setting the original lock state for site" $site.url "to prevent data loss"
  stsadm -o setsitelock -url $site.URL -lock $site.Lock
}</pre>
<p>You can download the script [Download not found]. Just make sure you run it with an account that has sufficient permissions as described in the <a href="http://technet.microsoft.com/en-us/library/cc262923(office.12).aspx">enumcontentdbs</a> TechNet article and to modify the first 4 paramaters.</p>
<p>Another option to move site collections is to use the <a href="http://technet.microsoft.com/en-us/library/cc508852(office.12).aspx">Batch Site Manager</a> that is included in the <a href="http://technet.microsoft.com/en-us/library/cc508851(office.12).aspx">SharePoint Administration Toolkit</a>. This tool is packaged as a solution that you deploy to your farm. When deployed (and activated), it will then have a new option in Central Administration under Application Management.</p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/12/BatchSiteManager.jpg"><img class="alignnone size-full wp-image-948" title="BatchSiteManager" src="http://mysharepointofview.com/wp-content/uploads/2010/12/BatchSiteManager.jpg" alt="" width="420" height="57" /></a></p>
<p>The tool allows you to very nicely see all site collection for each content database, select the ones you want to move and create a timer job for the move. The Batch Site Manager is using the stsadm operations backup and restore in the background. It usually takes a bit longer then the mergecontentdbs but you get the option to specify when the timer job should be run, where to store the temporary file and you can get a email notification telling you the status of the move. As you can see in the screenshot above the tool also offers you to batch locking and deletion of sites.</p>
<p>The Batch Site Manager is recommended to use with sites up to 15 GB. The mentioned recommendations for the both tools should be seen as recommendation and it&#8217;s possible to test your way forward and what works in your environment.</p>
<p>So what about really large site collections?<br />
When moving really large sites none of the mentioned tools might work and you will then have to take on a different approach. In short this is what you need to do.</p>
<ol>
<li>Set the site collection that needs to be moved (farm 1) to read only and make a SQL backup of the content database (ContentDB A).</li>
<li>Restore the content database with a new name (ContentDB B) and attach it to your Maintanence farm (Farm B) or if you don&#8217;t have one to a different web application. Make sure you use the –assignnewdatabaseid since we will later on restore the database back to it&#8217;s original location</li>
<li>When it&#8217;s attached to farm B, use the <a href="http://technet.microsoft.com/en-us/library/cc261873(office.12).aspx">stsadm -deletesite</a> operation using the -gradualdelete parameter (introduced in the April CU) to remove the sites from ContentDB B that should not be moved.</li>
<li>Backup the ContentDB B and restore it (but don&#8217;t attach it yet) to your Farm A</li>
<li>Delete the large site from ContentDB A using stsadm and -gradualdelete.</li>
<li>When the site is deleted you can attach ContentDB A to Farm A</li>
<li>Unlock the site collection when done.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/12/a-word-about-moving-site-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quotas and locks for sandbox solutions</title>
		<link>http://mysharepointofview.com/2010/10/quotas-and-locks-for-sandbox-solutions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quotas-and-locks-for-sandbox-solutions</link>
		<comments>http://mysharepointofview.com/2010/10/quotas-and-locks-for-sandbox-solutions/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 17:18:32 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Quota templates]]></category>
		<category><![CDATA[ResourceMeasures]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=893</guid>
		<description><![CDATA[When configuring Quota templates in SharePoint 2010 you will notice that a new section is added to the page. It&#8217;s called Sandbox solutions with Code Limits and is used to put a quota on sandbox solutions so that solutions that does not work properly will be shut down and not work when it reaches the maximum [...]]]></description>
			<content:encoded><![CDATA[<p>When configuring Quota templates in SharePoint 2010 you will notice that a new section is added to the page. It&#8217;s called <em>Sandbox solutions with Code Limits</em> and is used to put a quota on sandbox solutions so that solutions that does not work properly will be shut down and not work when it reaches the maximum daily quota. In this way we can limit sandbox solutions and protect our farm from poorly written code. As you can see on the screenshot below the values that should be specified (300 and 100 as default) are measured in points. So what is a point in this case? </p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/10/SandboxSolutionsQuotas.jpg"><img class="size-full wp-image-894 alignnone" title="SandboxSolutionsQuotas" src="http://mysharepointofview.com/wp-content/uploads/2010/10/SandboxSolutionsQuotas.jpg" alt="" width="527" height="91" /></a><a href="http://mysharepointofview.com/wp-content/uploads/2010/10/SandboxSolutionsQuotas.jpg"></a> </p>
<p>Microsoft has developed a way to calculate &#8220;problems&#8221;  within a solution based on a number of different metrics. To see what matrics are used you can use PowerShell and type the two following line of code in the <em>SharePoint 2010 Management Shell:</em> </p>
<pre>PS &gt; $spCodeService = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
PS &gt; $spCodeService.ResourceMeasures | select name</pre>
<pre>Name
----
AbnormalProcessTerminationCount
CPUExecutionTime
CriticalExceptionCount
IdlePercentProcessorTime
InvocationCount
PercentProcessorTime
ProcessCPUCycles
ProcessHandleCount
ProcessIOBytes
ProcessThreadCount
ProcessVirtualBytes
SharePointDatabaseQueryCount
SharePointDatabaseQueryTime
UnhandledExceptionCount
UnresponsiveprocessCount</pre>
<p>This will generate a list of all the Resource Measures. Each item has a number of properties that defines how the points should be calculated. If we take a closer look to the first item by typing: </p>
<pre>PS &gt; $spCodeService.ResourceMeasures["AbnormalProcessTerminationCount"]</pre>
<pre>MinimumThreshold                : 0
ResourcesPerPoint               : 1
AbsoluteLimit                   : 2
DiskSizeRequired                : 0
CanSelectForBackup              : False
CanRenameOnRestore              : False
CanSelectForRestore             : True
CanBackupRestoreAsConfiguration : True
Name                            : AbnormalProcessTerminationCount
TypeName                        : Microsoft.SharePoint.Administration.SPResourc
                                  eMeasure
DisplayName                     : AbnormalProcessTerminationCount
Id                              : 9056369d-768e-42bd-bd9c-67d810ad7936
Status                          : Online
Parent                          : SPUserCodeService Name=SPUserCodeV4
Version                         : 2410
Properties                      : {}
Farm                            : SPFarm Name=SharePoint_SP2010TestFarm_ConfigD
                                  B
UpgradedPersistedProperties     : {} </pre>
<p>In the above case the RecourcesPerPoint value is set to one. This means that whenever an Abnormal Process Termination occurs it will generate one &#8220;point&#8221;. You can also see that there is a AbsoluteLimit value. If any specific ResourceMeasure hits its AboluteLimit it will shut down the solution even if the daily quota of points is not reached. By typing the following you can see each ResourceMeasure&#8217;s ResourcesPerPoint and AbsoluteLimit values:</p>
<pre>PS &gt; $spCodeService.ResourceMeasures | select name, resourcesperpoint, absolutelimit</pre>
<pre>Name                                ResourcesPerPoint             AbsoluteLimit
----                                -----------------             -------------
AbnormalProcessTerminat...                          1                         2
CPUExecutionTime                                  200                        60
CriticalExceptionCount                             10                         3
IdlePercentProcessorTime                          100                        10
InvocationCount                                   100                       100
PercentProcessorTime                               85                       100
ProcessCPUCycles                         100000000000              100000000000
ProcessHandleCount                              10000                      5000
ProcessIOBytes                               10000000                 100000000
ProcessThreadCount                              10000                       200
ProcessVirtualBytes                        1000000000                4000000000
SharePointDatabaseQuery...                        400                       100
SharePointDatabaseQuery...                         20                        60
UnhandledExceptionCount                            50                         3
UnresponsiveprocessCount                            2                         1</pre>
<pre> </pre>
<p>It is possible to change the these values if you want to tweek how the points are calculated. To change the AbsoluteLimit on the AbnormalProcessTerminationCount you simply type: </p>
<pre>PS &gt; $spCodeService.ResourceMeasures["AbnormalProcessTerminationCount"] `
.AbsoluteLimit = 2</pre>
<p>If you want to change the Max Point quota for a specific site collection you can do that by typing: </p>
<pre>PS &gt; (get-spsite http://SPsiteURL).Quota.UserCodeMaximumLevel = 200</pre>
<p>Or of you want to change the quota on all site collections this is how you do. Get all site collections using the Get-SPSite cmdlet and then you pipe it to a foreach-object and then set the new value. </p>
<pre>PS &gt; Get-SPSite | foreach-object {$_.Quota.UserCodeMaximumLevel = 200}</pre>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/10/quotas-and-locks-for-sandbox-solutions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hide the quick launch navigation &#8211; the easy way</title>
		<link>http://mysharepointofview.com/2010/01/hide-the-quick-launch-navigation-the-easy-way/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hide-the-quick-launch-navigation-the-easy-way</link>
		<comments>http://mysharepointofview.com/2010/01/hide-the-quick-launch-navigation-the-easy-way/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 12:18:50 +0000</pubDate>
		<dc:creator>Mattias Karlsson</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[CEWP]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Quick Launch]]></category>
		<category><![CDATA[Stylesheet]]></category>
		<category><![CDATA[WSS]]></category>

		<guid isPermaLink="false">http://mysharepointofview.com/?p=707</guid>
		<description><![CDATA[Sometimes you have SharePoint lists or sites where you want to hide the Left hand navigation bar commonly called the Quick Launch. For instance it&#8217;s common that people want their News or Announcement lists that the visitor only have read access to, to only show all the news items and not the Quick Launch. Usually, if you have [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you have SharePoint lists or sites where you want to hide the Left hand navigation bar commonly called the Quick Launch. For instance it&#8217;s common that people want their News or Announcement lists that the visitor only have read access to, to only show all the news items and not the Quick Launch. Usually, if you have set the permissions correctly this is not a problem from an security point of view because of the Security trimming SharePoint have but it might look better.</p>
<p>There is a verry easy way to hide the Quick Launch if you only want to do this on or two pages.</p>
<p>This is how you do:</p>
<p>1. Go to the site or list where you want to hide the Quick Launch.</p>
<p>2. Go to <em>Site Settings</em> and select<em> Edit Page</em></p>
<p>3. Add a <em>Content Editor Web Part</em> to any of your <em>Web Part Zones</em> (This web part will be hidden so it doesn&#8217;t matter where you put it).</p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/01/AddWebPart.jpg"><img class="alignnone size-medium wp-image-710" title="AddWebPart" src="http://mysharepointofview.com/wp-content/uploads/2010/01/AddWebPart-300x139.jpg" alt="AddWebPart" width="300" height="139" /></a></p>
<p>4. Make sure that you select the <em>Hidden</em> attribute for the <em>Web Part</em> and the click on <em>Source Editor&#8230;</em></p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/01/EditContentEditorWebPart.jpg"><img class="alignnone size-medium wp-image-711" title="EditContentEditorWebPart" src="http://mysharepointofview.com/wp-content/uploads/2010/01/EditContentEditorWebPart-187x300.jpg" alt="EditContentEditorWebPart" width="187" height="300" /></a></p>
<p>5. A little bit depending on if it&#8217;s on a site, what kind of list, theme and if you have any custom styles on your site the below code could change but it will work in most cases and I will describe how you find make it work in case it doesn&#8217;t.<br />
Copy the below code and past it in the <em>Source editor</em></p>
<p>&lt;style&gt;</p>
<p>.ms-pagetitleareaframe<br />
{<br />
display: none;<br />
}<br />
.ms-navframe<br />
{<br />
display: none;<br />
}<br />
.ms-titleareaframe<br />
{<br />
display: none;<br />
}<br />
&lt;/style&gt;</p>
<p><a href="http://mysharepointofview.com/wp-content/uploads/2010/01/HideQuickLaunchCode.jpg"><img class="alignnone size-medium wp-image-712" title="HideQuickLaunchCode" src="http://mysharepointofview.com/wp-content/uploads/2010/01/HideQuickLaunchCode-300x172.jpg" alt="HideQuickLaunchCode" width="300" height="172" /></a></p>
<p>6. Click <em>Save </em>and then <em>Ok</em> in the Web Part Settings frame and finally exit the <em>Editing Mode</em></p>
<p>7. You should now have a page that does not show the <em>Quick Launch </em>and we have done this by overriding the style sheet. If parts of the navigation is still showing you need to override more attributes and to know which ones I recommend you to use the IE Developer Toolbar.</p>
<p>This IE plugin from Microsoft makes it easy to click on an object on a web site and show what attributes or classes it is using. If you are using IE 6 or 7 you can download it from here: <a href="http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&amp;displaylang=en</a></p>
<p>And if you are running IE 8 which is default in Windows 7 you have it already built in, how to use it can be found here:<br />
<a href="http://msdn.microsoft.com/sv-se/library/dd565628(en-us,VS.85).aspx">http://msdn.microsoft.com/sv-se/library/dd565628(en-us,VS.85).aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mysharepointofview.com/2010/01/hide-the-quick-launch-navigation-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

