Showing posts with label Administration. Show all posts
Showing posts with label Administration. Show all posts

Monday, 11 August 2014

Export SharePoint Managed Metadata Terms using CSOM and PowerShell


SharePoint 2013 out of the box has provision for importing metadata terms from a CSV file but there is no provision to export the terms that have been created. Exporting the terms can be accomplished by using Get-SPTaxonomySession powershell cmdlet. Unfortunately this cmdlet  is not available for Office 365 online so cannot be used to export metadata terms from SharePoint Online.

An alternate approach is to connect to SharePoint Online Taxonomy Session through CSOM and export the terms to a file. Below script uses CSOM and a recursive function to loop through metadata terms in SharePoint Online and write them to a file

#Specify admin user and SharePoint site URL

$User = “User Name”

$Site = "SharePoint Online URL"

#Adding references to SharePoint client assemblies

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll”

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll”

Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll”

 
$Pwd = Read-Host -Prompt “Enter your password” -AsSecureString


$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)

$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Pwd)

$Context.Credentials = $Credentials

$MMS = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Context)

$Context.Load($MMS)

$Context.ExecuteQuery()

 
#Get Term Stores

$TermStores = $MMS.TermStores

$Context.Load($TermStores)

$Context.ExecuteQuery()

 
$TermStore = $TermStores[0]

$Context.Load($TermStore)

$Context.ExecuteQuery()


#Get Groups

$Groups = $TermStore.Groups

$Context.Load($Groups)

$Context.ExecuteQuery()
 

#Create the file and add headings

$OutputFile = "Output File Path"


$file = New-Object System.IO.StreamWriter($OutputFile)

$file.Writeline("Term Set Name,GUID");


Foreach ($Group in $Groups)

    {

    $Context.Load($Group)

    $Context.ExecuteQuery()
 

    $TermSets = $Group.TermSets

    $Context.Load($TermSets)

    $Context.ExecuteQuery()

    Foreach ($TermSet in $TermSets)

        {

        $file.Writeline($TermSet.Name + "," + $TermSet.Id);

   
        $Terms = $TermSet.Terms

        $Context.Load($Terms)

        $Context.ExecuteQuery()

        Foreach ($Term in $Terms)

            {

                 $file.Writeline($Term.Name + "," + $Term.Id);

                 GetTerms($Term);

            }

        }

        $file.Flush();

          $file.Close();

 
        }
  

#Recursive function to get terms

function GetTerms([Microsoft.SharePoint.Client.Taxonomy.Term] $term)

{

 $SubTerms = $term.Terms;

        $Context.Load($SubTerms)

         $Context.ExecuteQuery();

            Foreach ($SubTerm in $SubTerms)

            {

            $file.Writeline($SubTerm.Name + "," + $SubTerm.Id);

            GetTerms($SubTerm);

            }

}

Note: Update the User, Site and OutputFile variables to values matching your environment.

Thursday, 12 June 2014

Creating SharePoint 2013 Subscription Settings Service Application

When trying to configure APP URL settings in new SharePoint 2013 environment, the configuration page displayed the message “The Subscription Settings service and corresponding application and proxy needs to be running in order to make changes to these settings” and didn’t provide any configuration options.


SharePoint 2013 Config App URL

Checking the services and service application in central admin showed that both the App Management Service and service application were created and running fine.  It took a while for me to realize that the Subscription Settings service application has not be created. This service application cannot be created from central admin UI but can only be created from PowerShell. Below are the PowerShell commands for creating the Subscription Settings service application


$acct = Get-SPManagedAccount <Account>
$appPool = New-SPServiceApplicationPool -Name SubscriptionServiceAppPool -Account $acct
$serviceApp = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -name "Subscription Settings Service Application" -DatabaseName "<Database Name>"
$serviceAppProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp

Once the Subscription Settings Service Application is created we will be able to configure App URLS .


Monday, 2 June 2014

Fix for Disabled Activate Solution button in SharePoint 2013

 

In a brand new SharePoint 2013 server installation, when you try to activate a solution after uploading the solution file to solution gallery you would see that the activate button is disabled even if you have logged in as the administrator. This will happen if the Microsoft SharePoint Foundation Sandboxed Code Service is not activated on the server. 
To fix the problem go to SharePoint 2013 central administration à System Settings à Manage Services on Server page and start the Microsoft SharePoint Foundation Sandboxed Code Service.  After starting the service you will be able to go to the solution gallery and activate your solutions.


Thursday, 17 April 2014

Using local accounts as a managed account in SharePoint 2013


A managed account is an account that is registered within SharePoint 2013 and can be assigned to SharePoint services. The advantage with managed accounts is that they are centrally managed and can be reused across services. However if you are on a SharePoint 2013 environment which is not connected to a domain and try to register a local account as a managed account from the central admin you will get an error

The specified user is a local account. Local accounts should only be used in stand alone mode


Registering local user account as a managed account can be accomplished by using the PowerShell command “New-SPManagedAccount” and passing the local account as the credential parameter. Below are the steps

1.    Get the credentials of local user account and assign to a variable

$AppPoolAct = Get-Credential <local user account>

2.    Execute the New-SPManagedAccount command and pass the variable to the credential parameter

New-SPManagedAccount –Credential $AppPoolAct

3.    The local account would be registered as managed account and warning message in yellow will be displayed.

Now we can use the managed account created in PowerShell for configuring service applications such as the secured store services in central administration.

Friday, 11 April 2014

Fix for Object reference not set to an instance of an object error when configuring SharePoint 2013 App URLs


When trying to configure App urls from SharePoint 2013 central admin you might encounter the dreaded error “Object reference not set to an instance of an object”.

 

SharePoint 2013 App URL configuration error


 Most common reason for the error is that you are trying to configure App settings without creating service applications and corresponding proxies for App Management Service and Microsoft SharePoint Foundation Subscription Settings Service.

 Below are the steps to fix the issue

1.       Start the App Management Service from central administration.

2.       Start the Microsoft SharePoint Foundation Subscription Settings Service from central administration.

3.       Configure the App Management service application and proxy from central administration or PowerShell

4.       Configure the Subscription Settings service application and proxy from PowerShell

 
Detail steps for  configuring App environment is available in the technet article http://technet.microsoft.com/en-us/library/fp161236.aspx

Tuesday, 4 February 2014

Rename SharePoint 2010 Central Admin Content Database


When a SharePoint farm is setup it creates a content database for the central admin site with a default name SharePoint_AdminContent_<GUID>. There would be situations where the database has to be renamed to adhere to company naming policies or for better manageability using automated scripts. The process of renaming SharePoint 2010 content database can be achieved with few lines of PowerShell Script

Create a new content database for SharePoint central admin site

First step is to create a new content database for the SharePoint 2010 central admin site using the New-SPContentDatabase cmdlet

New-SPContentDatabase -Name <DatabaseName>     -WebApplication <URL of SharePoint central admin site>

Get GUID of the content database for SharePoint central admin site

Get-SPContentDatabase PowerShell cmdlet will give the name  and id of the content database.

The syntax is

Get-SPContentDatabase –WebApplication  <URL of Central admin site along with port number>

This will list the old content database and the new content database.Copy the GUIDs of the databases in notepad or similar application.

Move the sites from old content database to new

Get-SPSite cmdlet will give the sites in a content database and Move-SPSite cmdlet will move sites to a particular content database. We can use combination of these cmdlets to move the SharePoint 2010 central admin content database.

Get-SPSite –ContentDatabase {GUID of old content database} |

    Move-SPSite -DestinationDatabase {GUID of new content database}