SharePoint online (o365) add-in workflow – AppOnlySequence

If you are going to use “AppOnlySequence” workflow activity in a SP add-in, make sure you follow the below activities in order to grant the required permission by the workflow to execute successfully. If you have missed any of the steps, then the workflow will be suspended with the error “Exception: Access denied. You do not have permission to perform this action or access this resource.”

Step 1:

Enable the feature “Workflows can use app permissions” at site level (site settings -> site actions -> manage site features):


Step 2:

In visual studio open AppManifest.xml and grant the app “Manage” permission.


Step 3:

Tick the option “Allow the app to make app-only calls to SharePoint”


You can also update the raw xml of AppManifest.xml with AllowAppOnlyPolicy=”true” instead of using the VS designer.


<AppPermissionRequests AllowAppOnlyPolicy=”true”>
<AppPermissionRequest Scope=”http://sharepoint/content/sitecollection/web&#8221; Right=”Manage” />


PowerShell: Download WSPs from solution gallery to a local folder

If you ever lost the WSPs installed in a production server or any server, following script can be used to extract and save all the WSPs to a local folder.

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

The Variations Create Hierarchies job failed


If you get the following message in variations logs (Site Actions –> Site Settings –> Site Collection Administration –> Variation Logs)  when the “Variations Create Hierarchies Job Definition” executed, it could be due to missing language packs.

“The Variations Create Hierarchies job failed with the following error message: File or arguments not valid for site template ‘CMSPUBLISHING#0’. Parameter name: WebTemplate.”

When installing a language pack in SharePoint 2010 Server make sure the following is followed.

Lets say for “Spanish” language pack

  1. Download SPF 2010 Spanish language pack from
  2. Install the Spanish language pack.
  3. Run the SP configuration wizard.
  4. Download MOSS 2010 Server Spanish language pack from
  5. Repeat step 2 & 3

Usage and Health Data Collection Proxy : Stopped

After installing and configuring SharePoint 2010 farm and if you notice that the “Usage and Health Data Collection Proxy” is still in the stopped state, follow the below to provision it.

Run the following PowerShell command to view the GUID of the service



Copy the Id of the SSA “WSS_UsageApplication”

Execute the following by replacing the GUID copied from above output.

$UP = Get-SPServiceApplicationProxy | where {$_.ID -eq "<GUID of the WSS_UsageApplication>"}




Now check the service status from central admin site.


SharePoint 2010 Managed Accounts

When you try to add a managed account to SharePoint 2010, it was throwing a error

“The specified user DOMAIN\SPFASTContentAdmAppPool could not be found. Some or all identity references could not be translated.”

But the user exists in the active directory. When I investigate further I found out that SharePoint does not accept user names which are more than 20 characters in length.

So new rule to the pre-installation documentation. “Manage account ids should be less than 20 characters”.


Publishing Pages : check-in file programmatically

One of the common scenarios when working with content migration is to handle the files checked out by other users. Following code is written to check-in all files check out by any users.

class Program
        static void Main(string[] args)
            Console.WriteLine("Please enter site url");
            using (SPSite site = new SPSite(Console.ReadLine()))
                using (SPWeb web = site.OpenWeb())
                    PublishingPageCollection publishingPages 
= PublishingWeb.GetPublishingWeb(web).GetPublishingPages(); foreach (PublishingPage page in publishingPages) { SPFile file = page.ListItem.File; if (file.CheckedOutByUser != null) { Console.WriteLine("The page {0} is check out by
user {1}. Check-in in to take control."
file.Title, file.CheckedOutByUser); file.CheckIn("checked in by script",
SPCheckinType.MajorCheckIn); SPModerationInformation moderationInformation
= page.ListItem.ModerationInformation; if (moderationInformation.Status
== SPModerationStatusType.Pending) { file.Approve("Approved by script"); } if (moderationInformation.Status
== SPModerationStatusType.Draft) { file.Publish("Published using script"); file.Approve("Approved by script"); } } } } } } }

How to convert a windows user name to claims user name using PowerShell

#read the user name

$claimsUserID = read-host -prompt ‘Enter windows user name in format DOMAIN\UserName :’

#convert the user name to claims id
$claimsUserID = New-SPClaimsPrincipal -Identity $claimsUserID -IdentityType WindowsSamAccountName

$claimsUserID = $claimsUserID.ToEncodedString()

#display the claims id
write-host ‘Claims user ID is ‘ $claimsUserID