Sunday 12 February 2012

Checking the Sandbox solutions settings using Powershell

Display the sandboxed solutions service configuration settings:


$uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local

foreach($tier in $uc.Tiers)
{
Write-Host "Tier Name: $($tier.Name)"
Write-Host "Tier MaximumWorkerProcess: $($tier.MaximumWorkerProcesses)"
Write-Host "Tier MaximumConnectionsPerProcess: $($tier.MaximumConnectionsPerProcess)"
Write-Host "Tier MaximumAppDomainsPerProcess: $($tier.MaximumAppDomainsPerProcess)"
Write-Host "Tier PriorityPerProcess: $($tier.PriorityPerProcess)"
Write-Host "Tier ResourceMaxValue: $($tier.ResourceMaxValue)"
}
 
Reference: http://technet.microsoft.com/en-us/library/hh230317.aspx

Thursday 9 February 2012

Authentication Evaluator

There are articles on building web parts to display claims on a page which can be a useful tool.
http://blogs.pointbridge.com/Blogs/nielsen_travis/Pages/Post.aspx?_ID=32
http://jopx.blogspot.com/2010/09/building-claims-viewer-webpart-for.html

Below I have added my own, nothing new or exciting but part of my discovery on CBA:
The code to display the current users Claim is shown below:
There is a codeplex project that provides a web part that display the Claim token.  As the code is so short I'd rater write it myself.

Saturday 4 February 2012

Presence Indicator not working

Problem: Presence indicator is not working in SP2010.

Initial Hypothesis: We have Office Communication 2007 installed.  I believe the presence indicator will also work if you are running Windows messanger on each client machine but our issue affected all our users in our test environment.

Resolution: A colleague, Greg Williams figured out how to fix the issue and I have posted it here to help others.  Neither the email address or the SIP are populated in the 'User Information' page (User Information List).
Here is the PS that fixed our issue, Brian Cartmel provided the PS:
$web = Get-SPWeb http://demo.dev
## get the user information list
$list = $web.Lists | where { $_.Title -eq "User Information List" }
## get the system account item
$item = $list.Items | where { $_["Account"] -eq "i:0e.t|ADFS20|paul.beck@demo.dev" }
$item["Title"] = "Paul Beck"
$item["SIP Address"] = paul.beck@demo.dev
$item.Update()



Explaination: "If the user does have a profile then the hyperlink will redirect to the user's main profile page under My Site. If the user does not have a profile, the hyperlink will redirect to the SharePoint Foundation 'User Information' page. All users in a site have a 'User Information' page, if they also have a User Profile the settings from the profile are synchronised down to the User Information page on a scheduled basis (by a timer job).
The key piece of information to make the presence work is the user's SIP Address which is basically their IM address (This is not always the same as email address). When a users is either added to a site in SharePoint or has their profile imported, the SIP Address will be drawn from Active Directory which is where OCS stores it and placed into the SIP address field in either the user's profile which will in turn synchronise down to the site's local 'User Information' page."  Martin Kearn

Tip: So as long as email or sip is populate with the email, the status indicator works.

More Info:
http://sharepoint.stackexchange.com/questions/15446/presence-indicators-without-lync
http://erikswenson.blogspot.com/2009/12/sharepoint-presence-not-showing.html
http://kbalertz.com/2448575/SharePoint-presence-information-appear-correctly-People-search-results-intermittently.aspx
http://blogs.msdn.com/b/uksharepoint/archive/2010/05/07/office-communicator-integration-presence-in-a-custom-webpart-for-sharepoint-2010.aspx (Read this)
http://blog.falchionconsulting.com/index.php/2011/12/updating-sharepoint-2010-user-information/
http://sharepintblog.com/2011/06/17/update-system-account-user-information-on-a-local-sharepoint-install/  Great blog and source of the Poweshell.

Wednesday 1 February 2012

Overview:  CKSDev provides mutiple SPI for SharePoint, the Event Receiver SPI is very useful in saving me tome writing all the plumbing code.

Problem: While updating a custom list using my event receicer I am re-firing the event receiver for the item.

Initial HypothesisDisable the event firing as shown in this post.  This post applies to MOSS and the methods have been depreciated in SP2010.

Resolution: Disable the EventFiring
this.EventFiringEnabled = false;
// Perform update
this.EventFiringEnabled = true;

SharePoint 2010 enable the scope immediately

Problem:  After creating a new scope, you need to wait 15 minutes for it to update the new scope (default SP2010 setting is: Automatically scheduled).


Initial Hypothesis: Gary Lapointe use to have a stsadm cmd to push thru the scope but I wanted to do it using PowerShell.  You can also use the Central Admin UI:


Resolution:
PS> $ssa = Get-SPenterpriseSearchServiceApplication
PS> write $ssa.name
PS> $ssa.StartScopesCompilation()
 

Technet has a post on forcing the scopes to update.

More Info:
http://gallery.technet.microsoft.com/scriptcenter/Force-to-update-Search-cf101b62
http://sharepointfieldnotes.blogspot.com/2011/07/sharepoint-2010-search-scopes-explained.html
http://blog.falchionconsulting.com/

Sunday 22 January 2012

Sandbox solution ULS logging

Overview: Step-by-step instructions to create a logging module for Sandbox solutions using a full trus proxy that logs to the ULS.

Steps:
1.> Ensure Sandbox solutions service is running:

1.1.> If the "Microsoft SharePoint Foundation Sandboxed Code Service" is stopped start it either thru CA (shown above or PS). 
PS> Start-Service -Name SPUserCodeV4


1.2.> Ensure the Windows service is running.

2.> Create project to test the full trust ULS logging proxy.
2.1> Create a Visual Studio project that deploys as a sandbox solution (test rig)

2.2.> Create a visual web part for sandboxed solutions (VSIX/Extension maneger: Visual Studion 2010 SharePoint Power Tools)

Note:  The submit button does not perform any action as the Full Trust Proxy must be created and deployed so we can use it to log code to the ULS.

3.> Create a ful trust proxy that code in the sandbox solution can call to add the error message to the ULS logs.

3.1.> Create an empty SharePoint project using Visual Studio 2010that deploys to the farm.
3.2.> CKSDev (VSIX extension has a SPI template to create a full trust proxy).  I used the SPI to create my ful trust proxy.
3.3.> Create the code to log to the ULS

3.4.> Edit the full trust proxy to use the ULS logging code created above.
4.> Add the proxy code call to the test rig/proxy caller i.e. sandboxed solution code.

Tip: Resart the Sandbox solution work process after each deployment



Tip: Use Powershell to check a correlation Id quickly:
PS>Get-SPLogEvent | ?{$_.Correlation -eq ""} | ft Category, Message -Autosize



References:
http://msdn.microsoft.com/en-us/library/gg622617.aspx
http://www.zimmergren.net/tag/sps
http://www.wictorwilen.se/Post/Working-with-SharePoint-2010-Correlation-ID-in-PowerShell-and-code.aspx

Tuesday 10 January 2012

Migrate MOSS site collection to SP2010

Problem: A common upgrade scenario I get in the role as a solutions architect is to move a site collection from a MOSS site to SP2010.
Initial Hypothesis: Do a side-by-side upgrade. Leave the existing site collection (or lock) it until the upgrade has the site collection on the new infrastructure. Don't go straight to production and I recommend doing the full upgrade on a standalone VM dev machine before even getting to test or production; this ensure the process works, is test and is repeatable.

Resolution: My suggested approach is to backup the content database containing the site collection, perform a “preupgradecheck and migrate it onto SP2010 on a dev machine. Next perform a backup of the site collection using CA or PS> as shown here Create the Installation Plan document that deploys the wsp’s and restore the site collection.  You can now move where the site collection to an existing content database.

More Info:
http://technet.microsoft.com/en-us/library/ee748617.aspx
http://blog.sharepointsite.co.uk/search?updated-max=2012-01-02T05:21:00Z&max-results=7