Sunday 16 October 2016

CSOM PowerShell: Create Term Store Management.

In this blog article, we will create a solution to create "ManagedMetaData Terms" which can be deployed on-premise, SharePoint Online (Office 365), or hybrid platforms.

The artefacts or functionality created using server-side or client-side techniques are not compatible, so they can be used to deploy solutions on any platform.


SharePoint PowerShell is a PowerShell API for SharePoint 2010, 2013, and Online. Very useful for Office 365 and private clouds where you don't have access to the physical server.

The API uses the Managed .NET Client-Side Object Model (CSOM) of SharePoint 2013. It's a library of PowerShell scripts, and in its core, it talks to the CSOM dll's.

The basic steps to implement CSOM PowerShell are:
1) Add Microsoft.SharePoint.Client.dll, Microsoft.SharePoint.Client.Runtime.dll and Microsoft.SharePoint.Client.Taxonomy.dll assemblies (which can be found in the ISAPI folder).
2) Create a ClientContext object.
3) Call the Load() and then ExecuteQuery() method.
4) Call the get and set methods using the ClientContext object.


Prerequisites for easily implementing the CSOM PowerShell script (optional).
Download the PowerGUI Script Editor IDE, which is free from http://en.community.dell.com/techcenter/powergui
It's a very powerful IDE for PowerShell, similar to Visual Studio.
It provides various features, like
1) Script Explorer.
2) Intellisense.
3) Variables and Call Stack.
4) Debugging and many more.


Steps to be used to create Term Store Management are:
1) Add dll's, create clientcontext and load (web and site) objects, and call the executequery() method.
2) Create the ManagedMetaData function and pass the clientcontext object.
3) Which reads the "ManagedMetaData.xml" file content (saved on the local drive).
4) Call the Get-TermStoreInfo function to get all groups and load them.
5) Check whether the group already exists or not, and then create it.
6) Then call the Create-TermSet function and pass the required parameters.
7) Again, check whether TermSet already exists or not, and then create TermSet.
8) Create Terms by calling the Create-Term function.










For more information, download the source from: click here


🚀 "Happy Coding" 🚀

No comments:

Post a Comment