Monthly Archives: January 2011

Chapter 9 – Sharepoint 2010 Web Parts

Wrox Real World Sharepoint 2010 (P.269)

Default CrateChildControls method uses Page.LoadControl to load the declarative user control from the _controltemplates virtual directory. That requires the ASCX file be deployed to the {SharepointROOT}\TEMPLATE\CONTROLTEMPLATES\ProjectName folder.

In ASP.NET, two ways to create application:
(1) Declarative:
<asp:TextBox Text”…”/>

(2) Imperative:
TextBox t=new TextBox();
t.Text=”Default Text”;

XSL List View (XLV) Web Part is used to display most Sharepoint List.

A Sharepoint web application will run a web part only if it is explicitly identified as SafeControl in web.config.
<SafeControl Assembly=”…………” NameSpace=”…..” Safe=”True” AllowRemoteDesigner=”True”…./>

The SafeControl element should always be added by Sharepoint Solution, not by hand.

Web Part Framework —
A minimum of two files make up a web part:
(1) web part definition (an assembly, derived from System.Web.UI.WebControls.WebParts.WebPart)
(2) web part template (*.webpart, and XML file)

Application Pages

are always found in the _layout
virtual directory. (SHAREPOINTROOT\TEMPLATE\LAYOUTS) Deployed using a farm solutions. Cannot be edited, created by end users.
Available to all sites in the farm.

Content Pages
– found in Content Databse. Two flavors (1) Instance pages and (2) Publishing pages.

*** Instance Pages

(system pages in publishing context) are content pages not based on Page Layout. Use the MasterURL property of the SPWeb object to decide which Mater Page to use.
Type of instance pages:
(1) Web Page pages – include web part zones
(2) Wiki Pages – One rich content area
(3) Meeting workspace tab page
(4) ASPX/HTML page – can onlt be created from Sharepoint Designer

examples of instance pages:

*** Publishing Pages
– based on a page layout
and stored in Pages Library. Use CustomMasterURL of SPWeb object to decide which master page to use.

Master Pages —
Master pages in the Master Page Gallery are for content pages
Master pages in _layout are typically for Application pages

Page Layouts —

*** All Publishing Pages must identity which Page Layout they are Using.
Publishing Page = Page Layout

Site Collection Web Part Galleries – (_catalogs/wp)
web part teplates uploaded to the site collection’s web part gallery are available anywhere within the site collection.
If web part template is orphanated for any reason, use this method to “new up” the template:
(1) Site Collection
à Web Part Gallery à Select New Document from the ribbon:

(2) Select a web part.

Web Application Web Part Gallery – (wpcatalog)
Web part templates placed in the physical wpcatalog folder just off the web app’s IIS root will show in all pages of all site collections within the web application.

Web Part Manager – a control that typically placed on master page to manage all moving parts of a web part zone.

Web Part Zone —
two types:
(1) WebPartZones: contains all web parts on a web page
(2) ToolZone: specialized zone that enables users to change the appearsance, behavior, layout and properties of the web aprts.

Web Part Ribbon —
For troubleshooting: add contents=1
t the end of URL and you see all the web parts on this page.

When you create a Sharepoint project in VS 2010, always select Empty Sharepoint Project.

(1) VS 2010, New Project à Empty Sharepoint Project à Name: Mindsharp.Webparts.RealWorld à Sandbox Solution
(2) Right click project root
à Add New Item à Visual Web Part à named FirstPart.
(3) Open the Elements.xml file in the web part folder, and change this property:

(instead of using “Custom”, we use a “RealWorld” as the category name)
(4) The featue will be deployed to {SharepointRoor}\TEMPLATE\FEATURES.
(5) Rename Feature1 to SiteFeature, double click it to show the Feature Designer
(6) Select “Site” (site collection) as scopt.

(7) Make sure Firstpart is in the feature

(8) Select View
à Other Windows à Package Explorer to show the package explorer

In Packaging Explorer, select Validate:

The validation will fail because Visual eb Part cannot be deployed as a sandbox solution. Once changed to Farm solution, validation will succeed:

Open the webpart ASCX file, Design View
à Add a Label, change to Code View, update the code:

****** A module feature is used to copy the web part template file into the Web Part Gallery. However, when a Module Fetaure is deactivated, it orphans the file in Content Database. To end users, it would seem like that they can still add the web part, but rather they get an error message. So when a Module Feature is used, housekeeping code is needed in the FeatureDeactivating method of the feature receiver.

In the *.cs file, add this line above the class:

To generate the GUID, in VS 2010, use Tools à Create GUID. CTRL-U to make sure all are lower case.

Go to Web Part property’s Feature Property, click the “…” button.

Click Add and change the key name to MyAssemblyQualifiedName

Type this in the value field:

Now build solution:

Right click Sitefeature, add Event Receiver:

Copy te following code in the FeatureDeactivating method:

Click the web part folder to set the Deployment Conflict Resolution property:

None – an error is thrown during a conflict
Prompt – display a prompt
Automatic – VS tries to solve the conflict

Deploy the solution:

Verify you can see the web part


Chapter 8 – Building Sandbox Solutions

Wrox Reall World Sharepoint 2010 (P.247)

Code Access Security (CAS) – a set of policies that control which functions can be performed by code based on a set of identification criteria. They don’t apply to assemblies in GAC. All Assemblies in GAC are automatically granted full CAS.

With a sandbox solution, the site administrator can deploy the solutions in solution gallery. Default for a sanbox solution execution is 60 seconds.

All of the resources used by the sandbox solutions are tracked, these resources are assigned points, and ultimately the system administrator allocates a maximum set of points to s site collections.

The resource quota is set at the site collection’s
level. Once the site collection reaches its quota of resource points, the solution in the site collection are shut down for the remainder of the day. You can chose to execute the SS in local or remote.

SPUCHostService.exe User Code Service, runs sandbox solutions. You can also define the CAS for the application pool.

Query (Resource) Throttling
– set at the Web Application level, prevents a query from running if they will return more than 5,000 rows.
(1) Administrator have a different quota that applies to them.
(2) Administrator can switch off the throttling feature (in list settings)
(3) “Happy Hour”

Resource Throttling – Central Admin Manage Web Application

Two restrictions with Sanbox Solutions
(1) CAS policy
(2) process token. (P.255)

Creating a Sandbox Project in VS 2010 —

In VS 2010, new project, Sharepoint à Empty Sharepoint Project à Sandbox Solution

Right click HelloWorld in Solution Explorer, and add a new Item
à Web Part à
Named HelloWorldWebPart

In VB Source:

F5 to run the app.

Change to Edit Mode, insert the Web Part.

So it’s working – a literal control

VS 2010 automatically creates a feature and package (*.WSP) for you.

From the solutions page you can see all solutions deployed to the server.

Going Out of the Sandbox —
To get out of the “sandbox solution” box, use a proxy application. And register the proxy with Sharepoint.
Implementing a proxy is a matter of overriding two classes – (1) argument class and (2) operations

argument class must derive from SPProxyOperationArgs and must be serializable.
operations class must derive from SPProxyOperation. Both need to be in GAC.

Chapter 7 – Working with Sharepoint Designer 2010

Wrox Real World Sharepoint 2010 (Page 205) 01/30/2011, 10:20PM

Sharepoint Designer 2010 WORKS ONLY WITH Sharepoint 2010.

Click the pin and you can preview the items in the section:

Logged in user. Click the icon (lower left) to see who the currently logged in user is. You can log in as a different user.

To configure Sharepoint Designer access, go to Central Admin à General Application settings à Sharepoint Designer. (first select the web application, then update SPD access rules)

If SPD access is enabled, you can select Site Actions à Edit in Sharepoint Designer

In Site Collection Administration, you can also allow/disallow SPD access:

When you open a page in SPD 2010, you see a Skewer Click in the ribbon. Click this button and select an element in the content, you can see the CSS used.

How to remove Recycle Bin and All Site Contents from the menu:

Open Master Page in SPD 2010, turn on Skewer Click, mouse over the area,…

Go to style tab, select CSS properties to display CSS properties.

Right click the style and select New Style Copy

This will copy the selected CSS into a new CSS. In the new style:

Once done, he two links are hidden.

In effect we created a new style that is slightly different from the old one – the visibility property is set to ‘Hidden’. (Page 224)

**** New Style Copy:
The new style is created inside the Master file, which is a recommended way of making style changes. Do not change the out-of-the-box CSS! You can also choose to have the CSS added to a separate file.

Forms —
Out o the box, most list forms in Sharepoint 2010 are ASP.NET forms, but with Sharepoint Enterprise 2010, it is possible to edit or create these forms using InfoPath.
To edit the form in InfoPath, click any list/library, and on the ribbon you see this button. You can customize the form by doing this.

InfoPath forms are automatically created for workflows when using Sharepoint server 2010. E.g., if you have a workflow that assigns a taks meant to be subkitted for approval, you could edit the task form and change it to provide more information.

Views and the XSLT List View Web Part —
Views are the primary way that content from lists and libraries is displayed to the user. In SPD 2010, you can click a list/library and go to the view section, and click on each view to update view

The views are based on XSLT List View Web Parts: With Sharepoint 2010, all forms are based on XSLT.

To create a new view, click the View button.

To set a current view as the Default View, click the button in the ribbon:

Editing Views and Forms with Sharepoint Designer —
(1) create a list with a few fields,
(2) customize the list form in InfoPath,
(3) edit the view to add conditional formatting, and
(4) create a custom view.

<1> Open SPD and connect to a site
<2> Click List and Libraries, and to create a new list, click “Custom List” in the ribbon. Name the custom list “Employee Review”.

<3> Go to the list’s settings/summary page, click “Edit List Columns” in the Customization section.

<4> Click “Title” and change it to “Employee Name”. Add a choice column by:

Enter 3 values as choices. Rename the column name to “Performance”

Add a third column, Comments, multiple lines of text

You have to click the Save button for the changes to stick.

<5> Now that the list is created, you can go to the web site and see the list:

<6> Now we want to modify the forms using InfoPath. In SPD, navigate to the list, open the list, and click Design Ofrms in InfoPath in the ribbon. Click “ITEM”.

<7> When the formis open in InfoPath, give a title, and remove the attachment row as we won’t use it.

<8> Once done, click the Quick Publish
button on the top:

<9> Now when you add a new item in browser, you see this form. (in either New or edit Mode)
<10> Now we can create custom view to help visualize and filter the data. Go to the list’s settings page. Click All Items View. In production, however, the best practive is to copy and create a new one.

<11> In the XSLT List View Web Part, remove the icon and keep the column.

<12> Then select the first cell

<13> While the cell is selected, click the button Conditional Formatting in the ribbon:

Enter this criteria:

and click “Set Style” to set the style for rows that matches this condition. Change the background color to green.

<14> Save it and go to the brwose to view the lsit. The employees that are “Exceeds Expectations” has green next to them:

<15> Lastly, to create a custom view that shows only yhe values of the employees who have a low rating.
<16> Go to the list, in the View section, click the new buton to create a new view. Called Low Rating. Edit it.
<17> Click the filter, and specify the condition:

<18> Browse the list, and you will see the new view:

<19> This view will display only the ones that does not meet expectation. Optionally, you can set style for this view (in this case, red). P.230

WorkFlows —
Sharepoint Designer 2010 supports the following workflow types:
(1) list workflow – directly assoicated with a list
(2) reusable workflow – can be associated with other lsits or libraries. Based on content type.
(3) site workflow – are not assoicate with a list or content type.
(4) globally reusable workflow – It is best to make copies and then modify.

SPD 2010 uses declarative rule-based workflows. Use conditions and actions to define the process. Click workflow in the navigation

Conditions: Rule and criteria that applied to the workflow. When started, the conditions are compared against the item being processed.
Actions: what activities are performed by the workflow. Such as, send email, or set a value in a field.

New workflow features:
(1) SPD 2010 supports Parallel Blocks – events can occur in parallel.
(2) Impersonation step —
(3) Lookup from Profile – can use user’s profile information in the workflow processing
(4) Modify the Out-of-the-box workflow – make a copy and modify!
(5) Import and Export Workflows to and from Visio 2010 —

Exercise: Creating a Site Workflow that Writes to a Custom List —
<1> Open SPD, click List and Libraries, click Workflow. Click Site Workflow to create a new site workflow.
<2> Name the workflow Employee Reviews and you see the designer.
<3> Before changing the workflow, click the Initiation Form button in the ribbon, and add a new field to the ini form, “Employee Name”, single line of text, empty default value.

<4> Create another parameter, Rating (choices), with 3 rating values.

<5> Ad another field, comments, multiple lines of text.
<6> While the blinking orange line is in the Step 1 box, click Actions
à Send an Email

Click these users to configure the email

<7> Click Action
à Create List Item

<8> Matching the parameters with the list items.

When finished:

<9> Next, Action
à Assign a to-do item

<10> Add a to-do item in someone’s task lsit. Define “someone” in the next step. Workflow will pause until this item is completed.

<11> Specify the user who will receive the task

<12> Completed workflow:

Save and Publish it.

<13> Testing the workflow –Go to web site, Site Actions
View All Site Contents
<14> on the top, click Site Workflow.

<15> Click Employee Reviews to start the work flow:

<16> You are prompted with an initiation form. Enter data.

<17> Then you will see the workflow inMy Running Workflow:

<18> Once you set the task status to “complete”, then the workflow will show “complete” in status.

Data Source —
Could be from Sharepoint, could be external data source such as SQL.
You can add a data source from an external SOAP data source:

Connecting to a Sharepoint web serivce with a Data View Web part —
<1> Click Data Source in the navigation, create a new Data source with SOAP connection
http://…./_vti_bin/webs.asmx?WSDL, select GetAllSubWebCollection to get all sites

<2> Once data source cretaed, create a web part site page: named AllSites.aspx

<3> First click inside the PlaceHolderMain to set focus, Data View à The data source you just created.

In the web part, you see a preview of all existing webs. Click the arrow of the first web, and make it a hyperlink.


Chapter 6 – Backing up and Restoring Sharepoint 2010

Wrox Real World Sharepoint 2010 (Page 165) 01/30/2011, 00:55AM

RTO: Recovery Time Objective
– max. Amount of time a recovery process should take in the event of failure.
RPO: Recovery Point Objective
– max. amount of data that can be lost in the event of failure.
RLO: Recovery Level Objective
– level of granularity needed when you restore.

Two primary type of recovery: (1) Content Recovery and (2) Disaster Recovery.

6 most comply used PowerShell commands when it comes to Backup and Restore:
(1) Backup-SPFarm
(2) Restore-SPFarm
(3) Backup-SPSite
(4) Restore-SPSite
(5) Export-SPWeb
(6) Import-Web

SQL Database Snapshots —
*** A SQL database snapshot functions like a separate, read-only copy of a regular database that is made at a specific point of time. Good: it’s small.
When creating a SQL snapshot, a special file type
Sparse File
is used – grows only when modification is made.
Wiki on Sparse File:

When backing up a site collection Sharepoint 2010, Sharepoint first creates a SQL Snapshot and then backup from the snapshot. So that users still can make changes while backup is in progress.

Granular Backup

In Sharepoint 2010, you can back up a single list or library.
Export using: Central Admin, STSADM, PowerShell
Import using: STSADM, Powershell

Export a list or library to a file: (select web Application, Site Collection, Site, List/Library)

Full site collection backup (will place read-only lock, unless using SQL snapshots)

or with STSADM
STSADM –o backup –URL http://xxx/xxx -filename e:\xxx\mybackup.bak
or with PowerShell:
Backup-SPSite http://xxx/xxx -path e:\backup\myback.bak (to use SQLSnapshot, add –UseSqlSnapshot)
to prevent read-only lock, use -NoSiteLock
to overwrite the same file (if exists), use -Force

Performing a site collection restore —
Restoring a site collection can’t be done in Central Admin. Use powershell or STSADM

A site collection backup preserves all internal details, such as GUID, and you cannot have duplicate site collection GUID in the same content database. So you must drop the original site collection before restore.
with STSADM:
STSADM –o restore –URL <url> -filename <filename> [-overwrite]

with PowerShell:
Restore-SPSite http://sp2010/hr –path e:\backup\mysite.bak
Use –force
to overwriting existing site collection
Use –ContentDatabase
to specify the destination content database to restore the content to. Sharepoint picks the [most available] content DB if this option is not specified.

Export a web site/list (called Export, not Backup)
with STSADM:
STSADM –o export –URL <url> -filename <filename>

with PowerSHell:
Export-SPWeb http://xxx/xxx/ -path e:\backup\mybackup.cmp
If only the “Shared Document” library:
Export-SPWeb http://xxx/xxx/ -path e:\backup\mybackup.cmp –ItemURL “Shared Documents”
If include user security, add -IncludeUserSecurity
If include all versions, add –IncludeVersions All

Performing an Import – can only use STSADM or PowerShell
with STSADM:
STSADM –o import –URL <url> -filename <filename>

With PowerShell:
Import-SPWeb http://xxx/xxx/ -path e:\backup\backup.cmp –Update Versions Ignore (ignore files that already exists)

Farm Backup

Performing a farm backup —
Central Admin: (Full/Differential, whether to backup content and configurations) Timer job is created.

You can only select one component to back up. Same with STSADM and Powershell.

STSADM –o backup –directory \\sp2010\backup\farm -backupmethod full
add –item <name> to backup individual component

Backup-SPFarm –BackupMethod full –Directory e:\backup\farm
add –ConfigurationOnly to backup configuration only
add –item “User Profile Service Application” to backup just the UP service application.

add –BackupThreads <number> to define the number of threads used for the backup

Scripting and scheduling your backups —
Write a powershell script, and schedule it in Task Scheduler.

Performing a Farm Restore —
Central Admin:

STSADM –o restore –directory <UNC> -restoremethod <overwrite | new> [-backup <GUID>] [-item <from showtree>]
The –backup GUID is the GUI id found in the spbrtoc.xml file in the backup folder.

Restore-SPFarm –Directory <UNC> -RestoreMethod <overwrite | new> > [-backup <GUID>] [-item <from showtree>]

Always deploy custom code to Sharepoint 2010 using SOLUTIONS (*.WSP).

01/30/2010, 11:59AM

Chapter 5 – Using PowerShell with Sharepoint 2010

Wrox Real World Sharepoint 2010 (Page 129)

The alias of Get-Help is help.

Right click the Sharepoint Management Shell
command, this is the link:
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoExit
” & ‘ C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1
‘ “

$ver = $host | select version

if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = “ReuseThread”}

Add-PsSnapin Microsoft.SharePoint.PowerShell

Set-location $home

Script editor: Windows Powershell Integrated Scripting Environment (ISE)

You need to manually run this command in ISE:
Add-PsSnapin Microsoft.SharePoint.PowerShell

Get-Member takes in any object and outputs info about the object’s public members.
Get-Member –InputObject $farm

In Powershell, an object’s type is represented by wrapping it in brackets (“[…..]”)

To instantiate a new object, you use New-Object

When declare a variable, you can do this:
$farm = Get-SPFarm or
[Microsoft.Sharepoint.Administration.SPFarm]$farm = Get-SPFarm (explicit declaration)

Read XML contents into a variable
[xml]$settings = Get-Content .\FarmConfiguration.xml

Initiate a hash table: $user = @{}

Wrapping in parentheses enable Powershell to evaluate, $($

Create an array:
$users=”Tessa”, “Pamela”

Object Pipe Line – pass an object from one command to another.

returns all commands with “Format”
Get-Command –verb Format

Filtering and Iterating —
Get-SPSite –Limit All | where {$_.Owner –like “wrox\spadmin”}
Get-SPSite –Limit All –Filter {$_.Owner –eq “wrox\spadmin”}

1..10 | ForEach-Object {

if ($_ -eq 5) {continue}

Write-Host $_


Functions and Scripts —

example: register an user account as a managed account.
function New-ManagedAccount {

$cred = Get-Credential “wrox\spfarm”

return New-SPManagedAccount -Credential $cred


save it as Function1.ps1 and run it and it will be loaded for later use. Or, make the account name a parameter:
function New-ManagedAccount([string]$accountName) {

$cred = Get-Credential $accountName

return New-SPManagedAccount -Credential $cred


function New-ManagedAccount([string]$accountName) {

$account = Get-SPManagedAccount $accountName -ErrorAction SilentlyContinue

if ($account -eq $null) {

$cred = Get-Credential $accountName

$account = New-SPManagedAccount -Credential $cred


return $account


Script file:

[string]$settingsFile = “Configurations.xml”


[xml]$settings = Get-Content $settingsFile

$settings.Farm.Accounts.Account | ForEach-Object {

New-ManagedAccount $_.Name


To run this script (with a parameter) do either one:
(1) CreateManagedAccounts.ps1 “configurations.xml”
(2) CreateManagedAccounts.ps1 –settings “configurations.xml”

gcm: Get-Command
gm: Get-Member

PipeBind Objects:
Objects that can be represented with different forms, such as SPWeb, SPSite: You can use URL, GUID, or site variable:
$site = Get-SPSite http://portal

$webs = $site | Get-SPWeb

$webs = $site.ID | Get-SPWeb

$webs = “http://portal&#8221; | Get-SPWeb

Commonly used cmdlets: FARM


Creates a new config database, and therefore, a new farm. Run only once each farm.


Connects a server to a config database – thus adding the server to the farm. Once per server in the farm.


Set required file, folder and registry access control lists (ACLS) for local server (must run once each server in the farm)


Install service sin the farm. Once per farm.


Install all the features available to the farm. Run once per farm using –AllExistingFeatures param.


Provision a Central Administration site on the local server. Typically run once per farm, but can be run on additional server as needed.


Install Help files


Installs any application content for the Central Admin. Run only once per farm on the same server as the first Central Admin site.

Commonly used cmdlets: SITE STRUCTURE


Create new managed account


Creating application pools for service applications.


Create a new web application


Creates a new content database for a specific web application


Create a new managed path for web application


Create new site collection


Create a new web


Set the actions that users can perform using Sharepoint Designer

Handling Disposable Objects —
A particular parameter is available to every cmdlets:
-AssignmentCollection <SPAssignmentCollection>

Purpose: store objects that implement IDisposable interface – such as SPSite, SPWeb and SPSiteAdministration.

<Global Assignment> Example:
Start-SPAssignment –Global
Stop-SPAssignment –Global

Creating Custom Cmdlets —

Chapter 4 – Sharepoint 2010 Security Under th Hood – Claims-Based Authentication

Wrox Real World Sharepoint 2010 (Page 105)

Kerberos uses secret key cryptography to provide strong authentication and cryptography over a network. Kerberos uses a key distribution center (KDC)
to safeguard information and broker ticket issuance.

Bundled identity information in a digital context is referred to as a TOKEN. (digitally signed) Each property is called Assertion.

Security Token Service (STS) —
Each of the token in a claim-based environment is generated by a STS.

User Browser à Sharepoint
Sharepoint à STS to ask for a token.
STS à Account store
STS Generate token à Sharepoint

**** Important definitions —
The STS is possessed by an Identity Provider (IDP), which is also known as an Issuer.
The consumer, Sharepoint, acting on behalf of the user, is also known as the Relying Party (RP).

If IdP is hosted on the same server as Sharepoint, it’s called IdP-STS. It’s very common because Sharepoint comes with its own STS, which has configured for AD DS.
If the STS outside of Sharepoint farm, then it’s called RP-STS.

STS converts a token into SAML.

When user has 2 identities, the STS will confuse. So a component called Identity Component is introduced.

ADFS (Active Directory Federation Services) —
Central component in a claimed-based environment is the STS, and ADFS is the platform. (ADFS 2.0) Supports both active and passive clients.

WIF (Windows Identity Foundation) —
allowing extranalization of user access through claims.

CardSpace —
Microsoft’s identity selector. Each card is an XML file.

Sharepoint 2010 includes a trusted STS, referred to as Security Token Service
web application. It’s in Sharepoint Web Service (IIS) as SecurityTokenService.

Chapter 3 – Monitoring Sharepoint 2010

Wrox Real World Sharepoint 2010 (Page 70)

ULS (Unified Logging Service)
– service responsible for keeping an eye on Sharepoint and reporting what it finds. It can report on 3 different locations:
(1) Sharepoint Trace Logs (…\14\LOGS\) NTFS compression
(2) Windows Event Log
(3) Sharepoint Logging Database

Sharepoint Trace Logs: …\14\LOGS\. By default, a new log is created every 30 minutes. Can change it to other times:
Set-SPDiagnosticConfig –LogCutInterval 60

Set events to monitor:
Central Admin à Monitoring àConfigure Diagnostic Logging. You see categories where you can select to monitor.

On that page you can change log path, how long to keep and max. log files size. Enable Event Log flood Protection.
Better to use PowerShell as there are other properties that can’t be accessed.

XXX-SPDiagnosticConfig: (GET/SET)
Set-SPDiagnostic –LogLocation e:\Logs


: clears out any changes you made, and set the logging level to the default values.

Correlation ID —

Globally unique GUID that is assigned to each conversation a user or process has with Sharepoint.

Click to set filter value

Filter by CorrelationID

Developer Dashboard —
The dashboard is loaded at the bottom of page. The user Must have AddAndCustomizePages permission to see the Dashboard. By default, off.
$dash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;

$dash.DisplayLevel = ‘OnDemand’; (or Off, On)

$dash.TraceEnabled = $true;

ULS Viewer Logger

Get-SPLogEvent | SELECT First 4
Get-SPLogEvent | SELECT
Last 4
Get-SPLogEvent | SELECT
First 4 Last 10

New-SPLogFile: To close out the current log file and start a new one.
Merge-SPLogFile: Merge all trace log files from all Sharepoint Servers in the Farm, into One. (creates a timer job to do it) Good for archiving log files.

Windows Events Logs —
Change windows event logs log level:
Central Admin
Configure Diagnostic Logging

Logging Database (Page 87)
a farm-wide repository of Sharepoint events from every machine in your farm. Get information from many locations and write into one single database.
Configuring: Central Admin à Monitoring à Configure Usage and Health Data Collection
You can enable (1) usage and (2) health data collection; usage data log location; health data collection schedule. And define Logging Database (default: WSS_LOGGING)

Use this command Set-SPUSageApplication to change the database server/name for LOGGING database
Set-SPUsageApplication –database server <servername> -databasename <dbname>

Consuming the Logging Daabse:
(1) Central Admin
à Monitoring à Reporting à View Administrative Reports (and other reports)

Health report: slowest page; most active users etc.
Web Analytics Report: statistics based on each web application, such as total number of page views, unique visitors, just like WebTrends.

On Web Analytics Report, click Analyze to change the report date range, or export to a CSV file.

To get usage information for any site collection, open Site Action à Site Settings à Web Analytics

You can also use SQL to consume Logging Database data.

Health Analyzer – use timer jobs to run rules periodically.
If there is an issue reported by Health Analyzer, you see a red bar on top when you open Sharepoint Central Admin:

Open each issue and you will see explanation and remedy etc. You can analyze again or repair it now:

Health Report Rules Definitions: 60 comes with Sharepoint 2010:

Timer Jobs —
Timer Jobs are XML files in the configuration database.
New feature: Run Now

Which server to run Time Jobs? (can be configured per content database)
Central Admin à Application Management à Database à Manage Content Database
Click content database name, scroll down to the bottom, and select the server that runs the timer jobs for this content database.

01/29/2011, 09:14AM

Chapter 2 – Upgrading to Sharepoint 2010 – Hybrid Approach

Wrox Real World Sharepoint 2010 (Page 35)

Visual Upgrade – allow user to switch look & feel back and forth between 2007 and 2010. Two options:
— preserve the user interface – use 2007 (use this!)
— upgrade to new user interface

Pre-Upgrade Checker – a STSADM extension for MOSS 2007 SP2. (better than prescan.exe of MOSS 2003) Can run on MOSS 2007 production and not changing any data.
Goal of the checker:
(1) whether your servers meet the core requirements for upgrading
(2) what currently exist insode the farm.

The STSADM command can be run from any machine in the farm. Can be run on each server to make sure configurations on all servers all are identical.

STSADM –o preupgradecheck

You can use the –localonly
switch to check only the local server.

During upgrade, twoupgrade files are created uner 12/LOGS:

Database Test cmdlet —
Test-SPContentDatabase: tes a content database against a web application to verify that all customizations are also installed in the web application. Also identity missing orphans, assemblies, site definitions and features. Use this command along with pre-upgrade checker.

Database attach approach allowed upgrading multiple content databases
at the same time.

Upgrade status is also displayed on Central Administration page.

With MOSS 2007 SP2, setting MOSS 2007 read-only is now supported.

In Sharepoint Administration Toolkit, there is a Batch Site Manager
with which you can move one or more site collections between exising Content databases.

Upgrading with Custom Site Definitions —
Site definition is a blue print for newly created sites, it defines what is added to the site when it’s being created. All are defined in ONET.XML.

***** When upgrading 2007 to 2010, Micrsofot use Upgraded Definition Files (UDF) to map and transform sites from MOSS 2007 to Sharepoint 2010.

MOSS 2007 Site Definitions à UDF à Sharepoint 2010 Site Definitions

Choosing the right upgrade path —
(1) In-Place Upgrade Approach – simpler. Downtime. All in one step.
— Install Sharepoint 2010 on all your MOSS 2007 servers.
— Run Sharepoint Products Configuration Wizard on the server running Central Admin.
— Better for smaller farms (< 15 GB)

All default job are set back to the default times, so be sure to document these prior to kick off an in-place upgrade.

farm configuration wizard – (central Admin) – provide very little control over naming of services and service applications.

To upgrade texonomy data: Move-SPProfileManagedMetadataProperty
First get the ID of the new User Profile Service Application by using Get-SPServiceApplicationProxy
Update-SPProfilePhotoStore – copy user photos from 2007.

If your MOSS 2007 uses FBA, it must be converted to Claim-Based Authentication (CBA) befroe FBA will work.

(2) Database Attach Upgrade Approach — Upgrading the contents only. Good if you’re chaning the hardware too –because you’re installing Sharepoiont 2010 on a different server.
— Can upgrade miltiple content databases simultaneously. Faster.
— Sharepoint 2007 configuration settings are not upgraded, must be done manually.
— All customizations must be moved manually.
— Sharepoint 2010 environment must be built and configured prior to attaching 2007 content databases for upgrade.

if you use InfoPath forms (admin-approved form templates and data connection files), you must perform extra steps:
— Form templates (*.XSN)
— Data Connection Files (*.UDCX)

My Site è User Profile service + Managed Metadata service

Sharepoint 2010 Hybrid Upgrade
(1) – Database Read-Only; minimum downtime

— in MOSS 2007, only Content Database can be made Read-Only.
— Tmake content database in read only mode (1) make database read-only and (2) disable timer jobs.

Sharepoint 2010 Hybrid Upgrade (2) – InPlace + Database Attach
— First detach content database (so in-place upgrade doesn’t upgrade the content DB) to detach:
STSADM –o deletecontentDB –URL http://Web_Applucation_URL –databasename NameofDB

— Upgrade in-Place
— re-attach Content Database, using:
Mount-SPContentDatabase –Name DNName –DatabaseServer ServerName –WebApplication NameofWebApp
— Primary advantage – upgrade multiple databases at the same time.

You can use a temporary Sharepoint 2010 Farm to upgrade your MOSS 2007 Content Database.

Chapter 1 – Building a Perfect Test Environement for Sharepoint 2010

Real World Sharepoint 2010

Here I am beginning to work on my 3rd Sharepoint 2010 book since last November. Hopefully by mass-reading these Sharepoint books I can quickly pick up something I need to learn about Sharepoint. In my life I rarely focus so much on something like I do with Sharepoint 2010.

Hyper-V is not supported on laptops. You can use VMWare or VirtualBox.

OS: Use Windows 2008 64bit SP2, or Windows 2008 R2. Web, standard, enterprise and data center allsupported.
Window 7/Vista – (good for developer machien)
(1) only stand-alone installation (single server),
(2) can’t use a real SQL server, and
(3) everything will be configured using a system or network account. (true)

After installaing windows 2008 VM, make it a domain controller.
Server Manager à Roles Summary à Add Roles à Active Diretory Domain Services

Use “dcpromo” to set up the domain (

Set registry DisableLoopbackCheck=1 to disable the security feature.

Disabling UAS (User Account Control) – (“Are you sure?”)
Start à Control Panel à System & Security à Change User Account Settings à Never notify.

Create Users!!!

Installaing SQL Server 2008 on the same VM (Do this before you do Sharepoint)

Installing Sharepoint 2010 —
— Pre-requite installer will install pre-requisite (download from Internet).
— Sharepoint doesn’t let you pick Stand-Alone or Farm if the installing server is a Domain Controller.

Installing Office web Application

Configuration Wizard –(Start à All Programs à MS Sharepoint 2010 Products à Sharepoint 2010 Products Configuration Wizard
(gray wizard) – connect to an existing farm, or create a new farm. (Farm à Configuration Database)
— connect or create a configuration database (use domain account as SQL username, such as contoso\sp_farm)
— enter a farm phrase. Save the passphrase.
— Specify a port number for Central Admin: 5555

Initial Farm Configuration Wizard – (from Central Admin)

(white wizard) —


Chapter 22 – Upgrading to Sharepoint 2010

MS Sharepoint 2010 Admin’s Companion eBook (P. 1035)

Focus on How to upgrade from Sharepoint 2007 to 2010 —

in-place upgrade – upgrading current Sharepoint configuration from its existing implementation to Sharepoint 2010.
migration upgrade (database attach) – creating a new Sharepoint 2010 farm and migrating your current database to the new farm. [Preferred]

10 best practices to upgrade to Sharepoint 2010
(1) Install SP2 to Sharepoint 2007.
(2) Ensure the exsiting Sharepoint 2007 is functioning. Remove all unused or unnecessary components.
(3) Migrate existing Sharepoint 2007 to 64-bit first.
(4) perform a trial upgrade on a test farm.
(5) Plan for hardware capacity.
(6) Perform a full backup for entire farm.
(7) If performing a database attach upgrade, set existing database to read-only.
(8) Avoid adding servers to new farm during upgrade.
(9) After the upgrde, review the logs.

Running the Pre-Upgrade Checker Tool —

(1) a list of all servers, components in the farm; whether meet the req. for upgrade.
(2) alternate access mapping (AAM)
(3) a list of all site definitions, site templates, features and languages packs.
(4) whether all customizations are supported.
(5) whether there are database or site orphans in the farm
(6) whether there are missing or invalid configuration settings in the farm.
(7) whether SQL server meets the req for upgrade.

stsadm -o preupgradecheck
(works in Sharepoint 2007, not in Sharepoint 2010)

The log file is available in: …..\12\LOGS\PreUPgradeCheck_YYYYMMDD_XXXXXXX.htm

Performing Database Attach Upgrade – preferred.
Can continue to use your current Sharepoint farm.
(1) Create a new Sharepoint 2010 farm
— Install Sharepoint 2010
— For each web application in 2007, re-create your web applications in 2010 (same default URL), re-apply configuration settings and copy over all customizations
— manually transfer customizations into Sharepoint 2010
— testing Sharepoint 2010
— Run stsad –o menumallwebs command to obtain a list of templates associated with each site.

(2) attach your current (2007) database to your new farm to complete the upgrade process.
— Attach your 2007 content database to your new 2010 farm
— Test-SPContentDatabase to test your old database
— stsadm –o addcontentdb (associate DB with farm)
The first content database that you add must contain the root site of the web application.
— verify the upgrade.

Performing an In-Place Upgrade —
Sharepoint is taken offline. Cannot roll back to previous version, or even pause the upgrade.
(1) run pre-requisite on all servers
(2) install Sharepoint 2010 on all servers. Run it on the server hosting Central Admin.
(3) install language packs
(4) Run Sharepoint Products Configuration Wizard on CentrL Admin, which upgrades the server, configuration database, service and content database.
(5) Run configuration wizard on the remaining servers.