I tried to get to the my Taxonomy session through the client object model. Well if you Bing (I actually used google. But I’m Microsoft focussed so I thought I better mention Bing here) and go to the Microsoft pages documentation the there isn’t much available. All I found is some empty pages.

So first of all load the dlls ( Make sure that you’ve got these dlls on your client!)

Add-Type -Path “c:\Scripts\Microsoft.SharePoint.Client.dll”
Add-Type -Path “c:\Scripts\Microsoft.SharePoint.Client.Runtime.dll”
Add-Type -Path “c:\Scripts\Microsoft.SharePoint.Client.Taxonomy.dll”

The first two are for the SharePoint Client Object Model. The 3rd dll is for the taxonomy stuff.

Then I setup the Client Object Model Context

$ctx = new-object Microsoft.SharePoint.Client.ClientContext($siteUrl)

Then like without the Client Object Model I need to get the session.

$session = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($ctx);

Ok, so now I’ve got a taxonomy session

Now I need to get to my TermStores

$termstores = $session.TermStores

I’m likely only to have one termstore, but just in case.

$termstores |% {
$termstore = $_;
if ($termstore.Name -eq “Managed Metadata Service”)
… More to come here …

Then to complete the above code I got my groups and groupset from the termstore

$groups = $termstore.Groups;

$groupset = $groups.GetByName(“My Company”);

$termsets = $groupset.TermSets;

$industrytermSet = $termsets.GetByName(“Industry”);

And my termset is available.

So now we’re nearly there.

I want to be able to get to my terms in a termset. So just a few more steps to go.

Now I’m getting all my terms ( I’ve only got 22 in this termset so no problem to pick them all up)

$industryterms = $industrytermSet.GetAllTerms()

Now to get my term all I need to do is:

$term = $industryterms.GetByName(“Aerospace”)

Hopefully this will help someone else.