How to create Commerce 2009 R2 SubSystems web services

Following are the steps help you to create Commerce subsystems web services like Catalog, Marketing, Order and Profile.

Step 1: Go to and select All Programs -> Commerce Server 2009 -> Tools -> Site Packager.

Step 2: Select option “Unpack from a package file”

Step 3: Browse to *.pup file and select Custom Unpack

Step 4: Select option “Add an application to an existing site”

Step 5: Select existing Commerce site for which you want to create web services

Step 6: Select web services you want to create

Step 7: Configure IIS, web site and virtual path for web services

Step 8: On Next click, web services unpacking will start. It may take a while to complete.

Step 9: Last you will see message Unpacking is Complete!!!

Check gallery for visuals.


Basics of PowerShell

PowerShell Overview
It’s a Command Line Interface (CLI) uses different approach to expose information rather than GUI. CLI’s don’t have any pattern that helps us to learn the interface. So we have to remember all the commands before enter to CLI. Also terse names are used over clear once.
Windows PowerShell is based on objects. Whatever we type in text is stored as objects and output of one can be easily passed as input to another command. Windows PowerShell is based on the .NET Framework. Syntax features and keywords of PowerShell are very similar to C# programming language. So knowing C# makes easier to work with PowerShell. Also learning PowerShell makes it much easier to learn C#.
Commands executed in PowerShell are known as cmdlets (pronounced command-lets)

How to use commands
Lets see how to reach a command without knowing its complete name.
First find all the commands nearly close to known keyword. E.g. to find a list of cmdlets that view and change Windows service.

 get-command *-service

Now from list we can choose one command which we feel more relevant as per our requirement. Then we get complete details about that command using get-help command.

 get-help get-service


get-service -?

We have figure out that get-service is the command that we needed. Let’s run this cmdlet to displays information about the members of the object output by the Get-Service cmdlet.

get-service | get-member

Cmdlets Naming
Cmdlets Use Verb-Noun Names to Reduce Command Memorization.
To list all commands that include a particular verb with the -Verb parameter for Get-Command. For example, to see all cmdlets that use the verb Get, type:

Get-Command -Verb Get

The -Noun parameter is even more useful because it allows you to see a family of commands that affect the same type of object. For example, if you want to see which commands are available for managing services, type following command:

Get-Command -Noun Service

Parameters with Cmdlets
Parameter names always have a ‘-‘ prepended to them when you use them, to allow Windows PowerShell to clearly identify them as parameters. In the Get-Command -Name Clear-Host example, the parameter’s name is Name, but it is entered as –Name.

The Help Parameter (?)
When you specify the -? parameter to any cmdlet, the cmdlet is not executed. Instead, Windows PowerShell displays help for the cmdlet.

Common Parameters
Windows PowerShell has several parameters known as common parameters. Because these parameters are controlled by the Windows PowerShell engine, whenever they are implemented by a cmdlet, they will always behave the same way. The common parameters are WhatIf, Confirm, Verbose, Debug, Warn, ErrorAction, ErrorVariable, OutVariable, and OutBuffer.
How to get syntax of a command
To get the syntax of the Get-Help cmdlet, use the following command:

Get-Command Get-Help –Syntax

Displaying Available Command Types
To get command aliases, which are the assigned nicknames of commands, type:

Get-Command -CommandType Alias

To get the functions in the current session, type:

Get-Command -CommandType Function

To display scripts in Windows PowerShell’s search path, type:

Get-Command -CommandType Script

Using Tab Expansion

Tab expansion is controlled by the internal function TabExpansion. Windows PowerShell allows you to fill in file names and cmdlet names by pressing the Tab key. To fill in a filename or path from the available choices automatically, type part of the name and press the Tab key. Windows PowerShell will automatically expand the name to the first match that it finds. Pressing the Tab key repeatedly will cycle through all of the available choices.

One limitation of the tab expansion process is that tabs are always interpreted as attempts to complete a word. If you copy and paste command examples into a Windows PowerShell console, make sure that the sample does not contain tabs; if it does, the results will be unpredictable and will almost certainly not be what you intended.

User Word Automation Service using PowerShell

With PowerShell also possible to use Word Automation Service to convert documents to pdf, xps, etc formats.

Execute below script in PowerShell on your SharePoint Server. Don’t forgot to make necessary changes in script as per your environment. Also Word Automation Service should be in running state.


$jobSettings = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJobSettings

$jobSettings.OutputFormat = "PDF"

$job = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJob("Var Word Automation Service", $jobSettings)

$job.UserToken = (Get-SPWeb http://VarSiteName).CurrentUser.UserToken

$job.AddFile("http://VarSiteName/Document%20Library/VarDocName.docx", "http://VarSiteName/Document%20Library/VarDocName.pdf")


For UI based solution check this link: SharePoint Document Converter

Play with SharePoint 2010 List using PowerShell

In this post, we will learn how to do basic operations on SharePoint list using PowerShell.

Lets start with List creation

$spAssigment = Start-SPAssignment    #Use to dispose SPWeb safely
$spWeb = Get-SPWeb ServerURL -AssignmentCollection $spAssignment     #Get SPWeb Instance
$spWeb.ListTemplates | Select Name, Description    #Display List of Templates Available
$spTemplate = $spWeb.ListTemplates["Custom List"]     #Create SPTemplate instance of Type Custom List
$spWeb.Lists.Add("List Title", "Description", $spTemplate)     #Add list to site

Add list to quick launch and fields to list

$spList = $spWeb.Lists["List Title"]    #Get list instance
$spList.OnQuickLaunch = $True    #Set true to display in Quick Launch
$spList.Update()    #Update list to reflect changes in site
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text      #Get Field type to create
$spList.Fields.Add("My Column", $spFieldType, $false)      #Add new field to list

Create View and set fields for view

$spViewQuery = “<OrderBy><FieldRef Name=”"Modified”" Ascending=”"False”" /></OrderBy>”
$spViewFields = New-Object System.Collections.Specialized.StringCollection    #Create string collection object
$spViewFields.Add("Title")    #Add columns
$spViewFields.Add("My Column")
$spViewName = "My View"        #Set view name
$spListView = $spList.Views.Add($spViewName, $spViewFields, $spViewQuery, 100, $True, $False, “HTML”, $False)    #Add view to list
$spListView.DefaultView = $True       #Set view as default
$spListView.Update()    #Update view to reflect changes in site

Add few List Items

$spListItem = $spList.Items.Add()    #Add new list item object
$spListItem["Title"] = "First Item"    #Set field value
$spListItem["My Column"] = "My Text for first item"
$spListItem.Update()    #Update list item object to reflect changes in site

$spListItem = $spList.Items.Add()
$spListItem["Title"] = "Second Item"
$spListItem["My Column"] = "My Text for second item"

Update List Items

$spListItems = $spList.Items    #Get list item collection
$spListItemsCount = $spListItems.Count    #Get list items total count
for($Counter = $spListItemsCount-1; $Counter -ge 0; $Counter--)
    $spListItem = $spListItems[$Counter]    #Get list item via index
    $spListItem["Title"] = "Updated Title" + $Counter
    $spListItem["My Column"] = "My Column" + $Counter

Delete List Items

for($Counter = $spListItemsCount-1; $Counter -ge 0; $Counter--)
    $spList.Items[$Counter].Delete()    #Delete list item

Delete List


Finally Dispose web object

Stop-SPAssignment $spAssignment

Happy Reading!!!

Extract WSP Solution files from SharePoint 2010 Farm

Before deploying updated WSP solution to SharePoint farm, administrators wish to take backup of current deployed solution in production servers just to stay on safe side. There is no option in CA to achieve this. Here is the script which gives us power to do.

(Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + "\" + $_.Name; $_.SolutionFile.SaveAs($var)}

To download single file use below script (Replace the YourSolutionFileName with actual WSP file name like abc.wsp):

$var = (Get-Location).Path + "\" + "YourSolutionFileName";(Get-SPFarm).Solutions["YourSolutionFileName"].SolutionFile.SaveAs($var)

$var = (Get-Location).Path + “\” + “YourSolutionFileName”; (Get-SPFarm).Solutions[“YourSolutionFileName”].SolutionFile.SaveAs($var)

Enable PowerShell ISE for Windows Server 2008 R2

Windows PowerShell ISE (Integrated Scripting Environment) is a host application for Windows PowerShell.In Windows PowerShell ISE, you can run commands and write, test, and debug scripts in a single Windows-based graphical user interface. Its features include multiline editing, tab completion, syntax coloring, selective execution, context-sensitive Help, and support for right-to-left languages.

By default this feature is shipped with PowerShell 2. If you are not able to find shortcut for Windows PowerShell ISE, it means you have to add this feature explicitly. Following steps will guide you how to add this feature:

Step 1 – Open PowerShell and Import Module Server Manager

            Exec command: Import-Module ServerManager

Step 2 – Now search for PowerShell ISE featurein Windows Features

            Exec command: Get-WindowsFeature -Name *PowerShell*

Step 3 – Verify PowerShell-ISE feature must present in above command result list. Now lets add this feature.

            Exec command: Add-WindowsFeature PowerShell-ISE

After executing above commands successfully. You can search Windows PowerShell ISE shortcut in start menu or simply type ise in PowerShell to open editor. There are few other ways to open PowerShell ISE that you guys can explore your own ;).

SharePoint 2010 File Storage System

SharePoint provide us a nice UI to store and read documents. But what happen behind the scene. Where it store all the files???

File System or Content Database

When we open document library in windows explorer view, SharePoint allow us to delete/update/add files as we do in the normal file system. So, what does it mean that files are stored in a physical location.

Nope. Not with SharePoint. It keep all the documents in a database. Ooooh database!!!

Doesn’t sound good to keep the documents in a database. What if my file size is big. Will it not slow down the performance as SQL BLOB operation are costly than accessing file from a physical path. Even SQL Express editions has limitation on database size (approx 10GB i think). Do to SQL storage, SharePoint allow file upload of max 2GB.

Cons with Content Database

– Costly SQL operations

– Limitation on file size

– Huge database size due to big files

Pros with Content Database

– Easy backup/restore process. As all data in one single file

With release of SharePoint, we have the option to configure storage of SQL Binary Large OBjects (BLOB) to physical file system. In SQL Server 2008 (including express 🙂 ), Microsoft provided an add-on feature pack called Remote Blob Storage (RBS) used for storage of BLOB to physical location.

Lets start how we can enjoy RBS feature with SharePoint 2010. Below post will explain how to configure RBS for SharePoint 2010.

Step 1. Select the Content database for RBS. (It is possible to limit the RBS per Web Application level)

a. Open Central Administration Site -> Application Management -> Manage Content Databases

b. Select Web Application for which you want to enable RBS. Note down the content database name for selected Web Application.

Step 2. Enable file stream on SQL Server 2008/R2 (including express edition)

a. Open SQL Server Configuration Manager -> SQL Server Services

b. Right click SQL instance on which SharePoint is running, and then select properties.

c. Select FILESTREAM tab -> checkbox Enable FILESTREAM for Transact-SQL access.

d. Select other checkboxes as per your requirement and click Apply -> Ok.

e. Open SQL Server Management Studio. Execute following query for Web Application Database as selected in step 1.

EXEC sp_configure filestream_access_level, 2

Step 3. Provision a BLOB store

a. Open SQL SERVER Management Studio. Execute below queries for Web Application Database as selected in step 1. Note: Replace WSS_Content as per step 1.

use [WSS_Content]
if not exists 
(select * from sys.symmetric_keys 
where name = N'##MS_DatabaseMasterKey##')
create master key encryption by password = N'Admin Key Password !2#4'
use [WSS_Content]
if not exists 
(select groupname from sysfilegroups 
where groupname=N'RBSFilestreamProvider')
alter database [WSS_Content]
add filegroup RBSFilestreamProvider contains filestream
use [WSS_Content] 
alter database [WSS_Content]
 add file (name = RBSFilestreamFile, filename = 
to filegroup RBSFilestreamProvider

Step 4. Install RBS.

a. Download installation package using links: X64 Package X86 Package IA64 Package

b. Install RBS client library on the web server. Note: Replace WSS_Content as per step 1 and DBInstanceName as per your SharePoint environment. Locate cmd prompt to download folder and execute following command.

msiexec /qn /lvx* rbs_install_log.txt /i RBS-x64.msi TRUSTSERVERCERTIFICATE=true FILEGROUP=PRIMARY DBNAME="WSS_Content" DBINSTANCE="DBInstanceName" FILESTREAMFILEGROUP=RBSFilestreamProvider FILESTREAMSTORENAME=FilestreamProvider_1

Step 5. Enable RBS

a. Open SharePoint 2010 Management Shell and execute following commands. Note: Replace WSS_Content as per step 1.

$cdb = Get-SPContentDatabase <ContentDatabaseName>
$rbss = $cdb.RemoteBlobStorageSettings

Step 6. Test RBS Installation
a. Browse to RBS directory store and confirm folder is empty.
b. Upload a file to SharePoint Web Application (of atleast size 100 Kb).
c. Browse to the file in the RBS directory store and open the file with the most recent modified date. This should be the file you have uploaded.

Cheers !!!

%d bloggers like this: