IT-Spirit Knowledge Base

To content | To menu | To search

Friday 31 December 2010

Scripting inside SharePoint with PowerShell - PART II Playing with lists and items...

This sample code show how you can script easily SP lists and items, this example lists all lists items for sites and sub sites and write the result into a text file:

[System.Reflection.Assembly]::LoadWithPartialName("Microsodt.SharePoint")
$logfolder = "c:\Logs"
$Siteurl = "http://sp.com"
$mysite = new-object Microsoft.SharePoint.SPSite($Siteurl)
$Filename "Report.txt"
$LogDate = get-date -uformat "%Y/%m/%d"
new-item -path $logfolder -name $Filename - type file -force
add-content -path $logfolder\$Filename -value "Date ; URL ; ListName ; ID ; Title ; Name"
$rootweb = $mysite.RootWeb
Foreach ($web in $mysite.Allwebs)
{
$lists = $web.Lits
foreach ($list in $lists)
{
$txt = "List Name:" + $list.Title
write-output $txt
$items = $list.Items
foreach ($listitem in $items)
{
$txt = $LogDate + ";" + $web.Url + ";" + $list.Title + ";" + $listitem.ID + ";" + $listitem.Title + ";" $listitem.Name
write-output $txt
add-content -path $logfolder\$Filename -value $txt
}
}
}
In few words, In the first loop we taking each web site and in the second loop we list all lists for this web site and in the third loop we taking specific attributes for each items.
In the next article we will see much operation and automation scripts for SP 2010 such as backup, restore, manage account, etc.

Sunday 14 November 2010

SQL Server Check List for Sharepoint 2007/2010 installation

This article review all things you need to think when you plan to install a SQL server for an Sharepoint 2007/2010 infrastructure.

Check list before the installation: 

_Virtual or physical server? Keep in mind that is not recommended to install SQL server for SP into a virtual machine due that SP consummes more disk i/o, storage, processor and memory.

_High avaibility? What else? It's strongly recommended to install SQL server in cluster, but now with SP 2010 you can use the SQL mirroring technologies to provide high avaibility if you do not want to use the MS cluszering technologie.

_Which version about SQL? Avoid SQL 2005 installation definitively. Focus your efforts on SQL 2008 installation. The First question is SQL 2008  or SQL 2008 R2? If you install a MOSS 2007 then choose SQL 2008 but if you plan to install SP 2010 then install SQL 2008 R2 or SQL 2008 SP1 with CU2 (this is mandatory for SP 2010). If your SQL servers have at maximum 8 CPUs, 64 Gb of memory and only two nodes in case of cluster installation choose SQL 2008/R2 Standard edition, if you have servers with more resources you must install the Enterprise edition.

_Dedicated SQL instance or not? For Sharepoint infrastructure you must have dedicated SQL instance and no other programs or applications installed on the SQL server because SP consume more disk i/o and storage. For SP 2010 it is recommended to install one SQL instance for the content databases and another instance for search databases.

_Plan your storage. Choose if it's possible a storage with great performance about disk i/o, plan to format each lun with 64K cluster size, and provision one lun for databases system + tlogs, one or many luns for SP content databases, one or many luns for tlogs about content databases. Apply the same policy for search databases, with SP 2010 it's better to have an another SQL instance to hosts the search databases. For better performance you can isolate the SP config and admin content databases on a separated and dedicated lun. 

_Plan your backup.  For the tool who backup your databases, I prefer to choose MS SCDPM, but if you don't have this tool, you can script a backup with the stsadm command line or by powershell cmdlet in SP 2010. In other case you can backup your databases with you backup software. To restore it, plan to have an another farm (recovery farm), that means to have sufficient storage on this farm and this farm ust have the level about templates, features, solutions, etc.

That all! This article has been write as is and provides some basics information for your governance plan about your infrastructure and to ask you the rights questions.


Saturday 30 January 2010

Configuring your web application with IIS 7.0 and Kerberos

This Article describes how to set Kerberos for your SharePoint Web Application, we consider that the kerberos is correctly confugured on the SQL side: SQL Service run with an Active Directory Account and the associated SPN is configured...

To create and configure web application with kerberos follow these steps:

  1. Create an Active Directory user account to run the IIS application pool.
  2. Set the SPN on this account.
  3. Trust Kerberos delegation on this account.
  4. Grant the rights "Local and Remote Activation" on the application pool account for the following DCOM object: IIS WARMREG ADMIN (for all web front end servers).
  5. Add the application pool account into the User Rights Assignments: "Act as a part of Operating System" (for all web front end servers).
  6. Create the web application with Host Header and select Kerberos for the authentication methods. Run the application pool with the application pool account created before.
  7. Edit the ApplicationHost.Config file on all web front end servers, locate this tag: <local path="name of yoursite">, next locate <windows security...> and modifify this tag as follow: <Windows security=.... UseAppPoolCredentials="TRUE" UseKernelMode="TRUE">
  8. Your are done.

Friday 22 January 2010

MOSS 2010 and Farm Configuration Wizzard Utility

A nice feature has been introduced with MOSS  2010: The farm configuration wieeard, this tools configure quickly your farm, web application and site collections, in our case we discuss about the service account and the rights granting by this wizzard into the system....

Go to your Central Admin page and read the following article.

After clicking on the Configuration Farm Wizzard, the system ask you for a service account, please create this account first in the Active Directory with no privilege only Domain Users.

Choose your services...

Note: In your example, we skip the site collection collection....

Ok now we have services configured, we look on our server the privileges granted by this setup for this account:

This account is member of: IIS_IUSRS, WSS_WPG, Performance Monitor Users.
This account have the following privileges: Adjust a Memory Quotas for a process, Logon as service, Replace a level token.

Sunday 10 January 2010

SharePoint 2010 Beta - First Contact

Prerequisites

First thing when you decide to test MOSS 2010 is to install an W2k8 64 bits, the SQL server must be a SQL 2008 64 bits SP1 with CU2.
After that launch the setup and read the following instructions (In our Case SQL and MOSS are installed on the same machine).
We decide to install the Farm in Kerberos authentication procotol.

Before to begin the MOSS installation you must install the following hotfix:

http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=21953

Good Thing

You can install prerequistes software automaticlally through internet!!!! The setup module Install IIS7 and configure it transparently!!!!
During the installation prerequistes the setup install the following softwares:

• Windows Server 2008 Service Pack 2

• Application Server Role, Web Server (IIS) Role

• Microsoft SQL Server 2008 Native Client

• Microsoft .NET Framework 3.5 SP1

• Windows PowerShell(TM) V2 (CTP3)

• Microsoft "Geneva" Framework Runtime

• Microsoft Sync Framework Runtime v1.0 (x64)

• Microsoft Chart Controls for Microsoft .NET Framework 3.5

• Microsoft Filter Pack 2.0

• Microsoft SQL Server 2008 Analysis Services ADOMD.NET

 

After Installing the prerequisites softwares, launch the setup installation MOSS program and choose the following options:

 

_Installation choice step, please choose Server Farm, look the Web Front options is not here....

_Server type step, please choose Complete install and leave the default options.

 

SharePoint Products Wizzard step

 

Before to launch the wizzard, please create two Active Directory accounts: One for setup MOSS and another one for Farm Admin purpose, for the Farm Admin account please set the SPN, grant this into IIS WarmReg Dcom object with local and remote activation. Grant the farm admin account local admin of the MOSS server. For the Setup MOSS account grant this into SQL with the following roles: DBCreator, SecuriyAdmin.

After that, log on the MOSS server with the setup account credentials and apply the following procedure:

 

_Create a New Farm.

_Specify the SQL instance and give theFarm Admin credentials.

_Wait few minutes,the setup is creating your farm.



New Security features during the setup wizzard: Passphrase to secure communication between farm, data and servers:



 

As you can see no great news about the installation, the new things is just to simplify the setup process with no choice between complete, web front or stand alone, juste Server Farm or Stand Alone and the last thing is the setup process is capable to dowlnload the requirement.

 




 

Saturday 17 October 2009

Exporting/Importing a Site Collection with a cab file (STSADM)

It's usefull to export Site Collection when you need to migrate your site between SharePoint farm, or just to pass from one environment to another envirnment (i.e :dev to QA).

On the source server:

Connect one of your MOSS server and type the following command:

stsadm -o export -URL http://your_site_collection -filename youtpath\your_filename.cab -cabsize 1024 -versions 1

Versions: 1 to 4, 1 for Major Version (default) ; 2 the current version, either the last major or the last minor; 3 Last major and last minor version for files and list items and 4 All versions for files and list items.

If you need to import the security, you can the following switch: -includeusersecurity.

Note:If you want to increase import performance add the following switch: -nofilecompression.

Technical reference: http://technet.microsoft.com/en-us/library/cc262759.aspx

On the target server:

Copy all the cab files from the source server to the target server, create a new web application befor to import the site collection, and type the following command:

stsadm -o import -URL http://your-web_app -filename path_of_your_cab_file_or_folder(nofilecompression only) -updateversions 1 to 3

Updateversions:

  1. Add new versions to the current file (default)

  2. Overwrite the file and all of its versions (delete then insert)

  3. Ignore the file if it exists on the destination

Technical reference: http://technet.microsoft.com/en-us/library/cc261866.aspx

 

Scripting inside SharePoint with PowerShell - PART I Getting Started...

Download the following tools:

_PowerShell for windows 2003: http://www.microsoft.com/downloads/details.aspx?FamilyID=10EE29AF-7C3A-4057-8367-C9C1DAB6E2BF&displaylang=en

_Powergui: http://www.powergui.org/downloads.jspa , this is optional but is a very useful gui for scripting and navigating between methods and class...

_Powerpacks for SharePoint: http://www.powergui.org/kbcategory.jspa?categoryID=354

Install all products and when you are finished to install Powergui, add the SharePoint packages.

Note:Keep in mind, you can write yourscript only on the WSS server because the remote commands does not exists, all tools must be installed on one of WSS server who is member of your farm. 

The basics...

When you write a script for WSS, the first line begin by:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Where-Object { $_.GetType().FullName -ne "System.Reflection.Assembly" } --->Recomended

OR

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") --->In some examples through Internet...

After loading into the GAC the DLL for SharePoint, you must to connect on the site where you need to script...

$SiteUrl = http://yoursite

#Creating your SP site object....

$Site = new-object Microsoft.SharePoint.SPSite($Site)

After that, you can display for example the site properties:

$Site.AllWebs | format-table | URL, LastItemModifiedDate, Created

Note: If you use the SharePoint PowerPack, you can browse through the $Site variable and you can see all propreties and methods.

 

 

 

Saturday 3 October 2009

How to upload new SharePoint Template?

First see if you have "Application Template" tab, when you create a new site, if not please follow this procedure:

Download the ApplicationTemplateCore file: http://www.microsoft.com/downloads/details.aspx?FamilyId=C1039E13-94DA-4D7D-8CAE-3B96FA5A4045&displaylang=en

Extract the WSP file and type the following command lines:

stsadm - o addsolution -filename <path>\ApplicationTemplateCore.wsp (result:Operation completed successfully.)

stsadm -o deploysolution -name Application TemplateCore.wsp -immediate -allowGacDeployment (result: Timer job successfully created.)

stsadmn -o copyappbincontent

 

If the Application Template Core is already deployed, please follow this procedure:

After you have extract the WSP file:

stsadm -o addsolution -filename <path>\Your_WSP_File

stsadm -o deploysolution -name Your_WSP_File -immediate -allowGacDeployment

After that check in the Solution management (Click the Operations tab, and then click Solution management under global configuration.) if your template is deployed (status is shown Globally Deployed), type the follwing command: iis reset.

You are done, one time you go to the Create Site, you will see under the Application Template tab, your template.

 

Sunday 2 August 2009

How to create HTTP Enpoint and Web Service without IIS?

Create HTTP endpoint can be usefull when you want to retrieve data on database without to install iis or to develop an application, in this exemple we create a Web Service who getdata in XML format by using a web service.

STEP 1: Create the store procedure.

CREATE PROCEDURE [dbo].[GetContacts] -->This store procedure retrieve Contacts from the Contact table...

AS BEGIN SET NOCOUNT ON;

SELECT TOP 20 [FirstName],[LastName] FROM
[Person].[Contact] ORDER BY [LastName];

END

STEP 2: Reserve the HTTP name space.

When you create an HTTP endpoint, you need to check if you don't have an IIS server runing, or if the port 80 is in used, after that youmust reserve the name of yourwebsite by the following command:

sp_reserve_http_namespace N'http://MyServer:80'  --> in this exemple the site http://MyServer is reserved.
GO

STEP 3: Create the HTTP Endpoint.

Select your database and execute this T-SQL script:

CREATE ENDPOINT AW_Contacts
STATE
= Started
AS HTTP
(
PATH
='/Contacts',
AUTHENTICATION
= (INTEGRATED), --> You can choose NTLM if you want...
PORTS
= (CLEAR),
SITE
='http://myserver'
)
FOR SOAP
(
WEBMETHOD
'GetContacts'
(NAME
='AdventureWorks.dbo.GetContacts'),
WSDL
= DEFAULT,
DATABASE
='AdventureWorks',
NAMESPACE
= DEFAULT
)

Your HTTP Endpoint is created, to access type the following URL: http://myserver/Contacts?WSDL

NOTE: Don't forget to fix the "Connect" right for the accounts who access on this web service.

 

 

Thursday 2 July 2009

Moving TempDB database on SQL 2005

Moving TempDB database on SQL 2005

When you configure your SQL server server it's important to move your TempDB databse on another disk, to do taht follow steps below: 

Use the following query:

use master ;

go

alter database tempdb modify file (name= tempdev, filename= 'target path\tempdb.mdf') ;

go ;

Repeat this command for each files linked on this DB.

Note: If you move on sql cluster, check that the target disk is include in the dependencies of the sql service.

KB Article: KB 224071.