Archive for the ‘Uncategorized’ Category

Links for 70-573 training

12. February 2011

Now and then I do training with the subject SharePoint 2010 development – and very often I talk about links for blog posts, tools, etc.. I find interesting. This is the collection, which of course will be extended whenever I find more interesting links.

Creating a virtual machine

Tools and extensions

Certification specific blog-posts

Optimizing your code

Fields, Content Types, Lists & Content Types – blog posts

Web Parts

Client Object Model

Search

Dates and the FullTextSqlQuery

Enterprise Content Management

Application Lifecycle Management

Administrative API

Videos and screencasts

The best error description

8. September 2010

Just got this beautiful baby of an error message from a FullTextSqlQuery in my Sharepoint 2010 development computer– awesome and very helpful errorJ

 

Why can’t I get a Document ID….??

6. September 2010

Got a scenario with SharePoint 2010, where I needed an Enterprise Wiki for an intranet-site and then as sub-sites for this a bunch of team-sites. One of the requests was to get the Document ID up and running, so my attempt was to go to site collection features and activate the Document ID Service feature….that should do….at least that was what I thought.

However, I found after playing a couple of hours on my dev-machine, it seems that if you need both document ID’s and the publishing feature, you have to activate the document ID feature before the publishing feature. In this case I had nearly no custizations made to the Pages-library apart from a couple of web parts added to the default-page.

After deactivating the site collection publishing feature (and destroying my pages-library), activating the document ID service feature, they both were working.

PowerShell and Sharepoint 2010 – Part 2 : Reading the ULS log

20. April 2010

Some part of problem solving in Sharepoint is done through the ULS logs which by default is placed in the Logs-directory of the RootFolder of your Sharepoint installation. In Sharepoint 2007 you need to manually search the text-files for the terms that might have caused problems for the user and then try to connect the event log and the uls-logging times and figure out what happened. While this is still the truth in SharePoint 2010 PowerShell has made it increasingly easier to scan the log for whatever error you might have. So grab a PowerShell command prompt and type Get-SPLogEvent and watch the complete ULS appear across your screen. This is not very helpful and takes a bit of time, so we need to do some filtering.

Date and time filtering

First of all we need to do some date-filtering. If you only want errors from the last five minutes, you can filter by giving the command a start property in a format like the following: Get-SPLogEvent –StartTime (Get-Date).AddMinutes(-5) which obviously will take and calculate a start time from current time (which is provided by the get-date method, and the add negative five minutes, which will give the log for the last five minutes. Note that an endtime is available in the exact same way

Chosing what columns to see

Still I get no idea, what the error is – only stuff like EventID, The time the error occurred and stuff like that appeared in the above command. This must be available in a more detailed form. And of course it is. By sending the results of the Get-SPLogEvent command into a select statement, you can choose exactly what columns to show. So grab the PowerShell command again and write Get-SPLogEvent –StartTime (Get-Date).AddMinutes(-5) | select timestamp, message and you will get the timestamps and messages of all messages from the last 5 minutes. Available columns are:

  • TimeStamp
  • Continuation
  • Process
  • ThreadID
  • Area
  • Category
  • EventID
  • Level
  • Message
  • Correlation
  • Context

 

So a select * instead of select message will return every field in a format not very nice J

So final thing is to decide what columns you like, grab them and format them in a usefull way. Format-table I excellent for this, and passing the following command is often usefull: Get-SPLogEvent –StartTime (Get-Date).AddMinutes(-5) | select * | Format-Table –Wrap

Filtering on these fields

A filtering on any of the fields above is available to prevent admins from looking at everything, when they have an idea of where to look. Especially the new correlation id is handy to filter. It is provided on nearly any error message in the user interface and provided again in the log files. If you want to query the logs for a specific error you can do it by providing the SPLogEvent –StartTime (Get-Date).AddMinutes(-5)| Where-Object {$_.Correlation –eq “yourFancy CorrelationID”} | select timestamp, process, level, message, correlation | Format-Table –Wrap

Have fun J

Enabling State Service in SharePoint 2010

21. March 2010

State Service in SharePoint is a service that keeps temporary data across http requests in a SQL database, and is required in Sharepoint 2010 if you want to edit your list-form in Infopath 2010. However, it seems very difficult to enable this unless you use the farm configuration wizard, which basically creates a database and an application pool where you have no control of the names. If you want control, you’re in need of PowerShell – so here is a tiny very un-debugged PowerShell script I use every time I have a clean Sharepoint 2010 install.

In short terms it enables the service, and creates a service application and puts it in the default proxy group:

Write-Host ******************************************************* -ForegroundColor Blue
Write-Host * Session State Enabler for Sharepoint 2010 -ForegroundColor Blue
Write-Host ******************************************************* -ForegroundColor Blue

#Check if the Sharepoint snapin is enabled
$spSnapin = Get-PSSnapin| Where-Object{$_.name -eq ‘microsoft.sharepoint.powershell’}
if($spSnapin -eq $null)
{
    Write-Host adding Sharepoint Snapin -ForegroundColor Green
    Add-PSSnapin microsoft.sharepoint.powershell
}

$StateServiceApp = Get-SPStateServiceApplication
$stateService = Get-SPSessionStateService

if($stateService.SessionStateEnabled -eq $false)
{
    Write-Host Starting the service -ForegroundColor Green
    $dbName = Read-Host “Enter service database name”
    Enable-SPSessionStateService -DatabaseName $dbName

 

}

if($StateServiceApp -eq $null)
{
    Write-Host Session State disabled -Starting Session state -ForegroundColor Green
    $dbName = Read-Host “Enter serviceapplication database name” 
    $StateServiceApp = New-SPStateServiceApplication -Name “State Service application”
    New-SPStateServiceDatabase -Name $dbName -ServiceApplication $StateServiceApp
    New-SPStateServiceApplicationProxy -Name “State Service Proxy” -ServiceApplication $StateServiceApp -DefaultProxyGroup

    

if($SessionState.SessionStateEnabled -eq $true)
    {
        Write-Host Session State Started -ForegroundColor Green
    }
    else
    {
        Write-Host Session State did not start successfully -ForegroundColor Red
    }
}
else
{
    Write-Host Session State already enabled -ForegroundColor Green
}

Have fun J

Figuring out how to make a site definition with the new Wiki-frontpage

23. December 2009

The new Wikii-frontpage of the Sharepoint foundation Team sites is a very user friendly feature since you will have the best possibilities of creating custom content in your pages without having to using the good old Content Editor Web Part from WSS 3.0. It is situated in a library called SitePages.

As a siteAdmin you can enable this in site features by activating the Wiki Page Home Page feature on every site needed…..but how the heck is it done from a site definition?

Reverse engineering is the way ahead….and the standard team site has the function enabled, so a good place to start searching is in 14\template\sitetemplates\sts\xml where the ONET.XML for the team site, blank site and document workspace resides.

Configuration 0 is the teamsite, and at a first glance there are no lists called SitePages and no modules ghosts a page called home.aspx. Looking a bit better the following lines might do the trick:

<WebFeatures>

<!– WikiPageHomePage Feature –>

<Feature
ID=00BFEA71-D8FE-4FEC-8DAD-01C19A6E4053 />

</WebFeatures>

…so basically it is a webfeature and adding this line in your WebFeatures of your site definition will make a sitepages library for your sitepages and a default page called home.aspx. It will also create a library called Assets for e.g. pictures.

Enabling the Developer Dashboard in Sharepoint 2010

23. December 2009

Introducing the Developer Dashboard in Sharepoint 2010, developers will get the tool they were looking for: A dashboard saying how long time the custom code took to execute, what queries were ran at the sql server and a lot of other fun stuff…..only problem…..it pro’s and end users doesn’t care about it, and therefore it is disabled by default – and there is no button the enable and disable it.

How is it done then…..there are three options, stsadm, PowerShell or custom code. In this blog-post we will be dealing with the code-option

The code-attempt

Open Visual Studio 2010, create a new Console Applicaton and make sure the .Net Framework 3.5 is chosen in the top…..SHarepoint has no idea of what .Net Framework 4.0 is.

Change the build setting of the project from x86 to any CPU in the project properties and save them.

Include the namespace of sharepoint administration by pasting the following just beneath the other using-statements:

using Microsoft.SharePoint.Administration;

And finally paste the following lines of code in your Program.cs files in static void main

SPWebService contentService = SPWebService.ContentService;

contentService.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;

contentService.DeveloperDashboardSettings.Update();

This will enable the developer dashboard for the entire farm – and it will look something like this:

Have fun J


Follow

Get every new post delivered to your Inbox.