How to find list internal name in SharePoint 2013

​Someone asked me this question as to how can they find the internal name of the list in SharePoint 2013. I initially thought there will be internal name property for the field but there was none.

In the end PowerShell came to the rescue. You can run the following simple PowerShell script to get the internal name for any list in SharePoint 2013.

$web = GetSPWeb “http://intranet.contoso.com”  // Replace web URL with your web. $list = $web.Lists[“Project Issues and Risks”] // Access list using its Title

WriteHost $list.Title  // This will return the title of the list WriteHost $list.Rootfolder.Name //This should return the internal name​

That is all it needs to get the List internal name.

Automating SharePoint Online Tasks (O365) using PowerShell + CSOM – Part 2

This is my second blog post in the Automating SharePoint Online using PowerShell + CSOM Series. In the last article we saw how to authenticate against SharePoint Online site and how to access Web and List using PowerShell + CSOM. Here is the blog post.

Automating SharePoint Online Tasks (O365) using PowerShell + CSOM – Part 1​

Just reiterate, we are going to create site columns and content types and then adding site columns to content type and then finally adding content type to list.

So today I am going to show you how to write a code to create a site column using PowerShell and CSOM.

Continue reading “Automating SharePoint Online Tasks (O365) using PowerShell + CSOM – Part 2”

SharePoint 2013 and Registering Workflow Manager

This one will be a quick post on Registering Workflow Manager in SharePoint 2013 environment.

​If you receive the following error during registration of the Workflow Manager then you might be running into the same issue as me.

Register-SPWorkflowService : Failed to query the OAuth S2S metadata endpoint at URI

I searched on this error and most people suggested creating host entry to the server because workflow manager could not connect to SharePoint Server. This was not my scenario given I was using Workflow Manager with SharePoint farm and all servers were able to connect each other.

After some searching I found the following blog post.

http://www.sharepointing2010.com/2013/11/resolved-register-spworkflowservice.html

Now before executing these steps I wanted to confirm why we needed to do this. So on further research I came across the following blog post from Steve Peschka.

http://blogs.technet.com/b/speschka/archive/2012/07/23/setting-up-an-oauth-trust-between-farms-in-sharepoint-2013.aspx​

Though it talks about setting up OAuth trust between farms it does mention one of the option which was also suggested in the blog above i.e.

if you are not going to be running your web apps over SSL, then you will need to set the AllowOAuthOverHttp property to true as well.  Here’s a little PowerShell that demonstrates how to set these properties:

$c = GetSPSecurityTokenServiceConfig

$c.AllowMetadataOverHttp = $true

$c.AllowOAuthOverHttp = $true

$c.Update()


​After running these commands I was able to register workflow manager without any issue.

 

Automating SharePoint Online Tasks (O365) using PowerShell + CSOM – Part 1

Today I am going to start a new series of automating some of the SharePoint online (O365) tasks using the PowerShell and Client Side Object Model (CSOM). Anyone who have worked on SharePoin Online knows that there are not as many PowerShell cmdlets as On-Prem. So if you used to automate tasks using PowerShell in On-Prem scenario, you will soon find that SharePoint Online does not have that flexibility. The option is to extend this using PowerShell and CSOM.
I am not going to be going in too much detail on this as Chris O’Brien have posted a really good blog post on this. You should read that article first before proceeding.
Basically what I am going to post is code on different SharePoint Online tasks. In next few parts what I will be covering is how you can create Content Types, Site Columns, Add Site Columns to Content Type and then Add Content Type to a List.
In this blog post I will show you, how you can access a web and then a list using PowerShell and CSOM. Once  you get the list how you will change Allow Management of Content Type option to True.
So lets start.
First step is to Authenticate against your O365 SharePoint site. If you have read the blog above by Chris, it has the code for the same. I would say create a PS1 file using that code and then use that code in your any other code. So for the sack of this blog post I am assuming that you copied the code from above blog post and called that PowerShell AuthenticateO365.ps1.
So next step is to Get List and then enable Allow Management of Content Type option. Here is the code for that.
# ……START Authenticate………………..
    .\1_Authenticate.ps1
    #……..END Authenticate…………………
    #……..START – Update List……………………
    $web = $ctx.Web 
    $list = $web.Lists.GetByTitle(“SPSBoston”)
    $ctx.Load($web) 
    $ctx.Load($list)
    $ctx.ExecuteQuery()
    Write-Host “Current list title is ‘$($list.Title)'” -ForegroundColor Yellow
    Write-Host “”
    $list.ContentTypesEnabled = $true
    $list.Update()
    $ctx.Load($list)
    $ctx.ExecuteQuery()
    Write-Host “List Content Type Enabled: ” $list.ContentTypesEnabled -ForegroundColor Yellow
    #……..END – Update List……………​

Updating List Template after Saving List as Template

Many time you will run into a situation where you will save a list and/or library in SharePoint as a template. After saving list/library as template you may want to change some of the settings e.g. You saved document library as template which had Major Versioning enabled. Now you want to turn minor versioning enabled as well. 
One way to handle this is to make change in the document library and save it again as a template again. 
I am going to show you how you can actually modify the existing library template and re-upload it again. Following are the steps.
Note: In this example I have saved document library as template and I am going to change Versioning setting on library level.
1) Download the Document Library Template from the list template gallery and save it to local drive e.g. C:\Temp
2) All list templates are CAB files so you can simply rename list template (STP) file to CAB file.
3) Now that you have CAB file extract the CAB file that will give you manifest.xml file.
4) Open manifest.xml file in Visual Studio for editing. For enabling major and minor version in document library template make sure you include VersioningEnabled and EnableMinorVersions properties and set them to TRUE. Here is the example:
<List Name=”{CB2342B1-0650-4059-857E-F8916A954C70}” Title=”Documents” Description=”This system library was created by the Publishing feature to store documents that are used on pages in this site.” Direction=”0″ BaseType=”1″ FeatureId=”{00BFEA71-E717-4E80-AA17-D0C71B360101}” ServerTemplate=”101″ Url=”Documents” VersioningEnabled=”TRUE” EnableMinorVersions=”TRUE” MajorVersionLimit=”0″ MajorWithMinorVersionsLimit=”0″ 
5) Once you make the change save the file. Now you are going to reverse engineer to create new CAB file from scratch. We will use MakeCAB.exe for this.
6) First open a NotePad and paste the following code in it.
OPTION EXPLICIT ; 
.Set CompressionType=MSZIP ;
.Set Cabinet=on
; Destination Folder
.Set DiskDirectory1=c:\Temp
; File name for the new cab file. This will be your List Template name.
.Set CabinetNameTemplate=SharedDocuments.cab  
; Files to be added are listed below
c:\Temp\manifest.xml
7) Save file as docTemplate.ddf and then run the following command to create CAB file.
makecab /f c:\Temp\docTemplate.ddf
8) This should give you  your CAB file. Next step is to simply rename the CAB file to STP and upload it back to list template gallery.

 

REST API How To: Get specific user permission for specific item in Sharepoint 2013

I have been spending some time with REST APIs when working with SharePoint 2013. Today I am going to share with you some RESP API code samples related to getting SharePoint Site/List/List Item permissions using the REST API.

To get permission for specific site for particular user you can use

http://intranet.contoso.com/_api/web/getusereffectivepermissions(@user)?@user=%27i%3A0%23%2Ew%7Ccontoso%5Cbrianc%27

Here the username is in this format i:0#.w|contoso\brianc for Windows Claims. This will change for SAML Claim

To get specific list permission for particular users you can use

http://intranet.contoso.com/_api/web/lists(guid’F27BDE7D-340F-43F4-B606-D24E02D0D01C’)/getusereffectivepermissions(@user)?@user=’i%3A0%23%2Ew%7Ccontoso%5Cbrianc’​


​And finally to get permission for a list item for particular user you can use

http://intranet.contoso.com/_api/web/lists(guid’F27BDE7D-340F-43F4-B606-D24E02D0D01C’)/getitembyid(16)/getusereffectivepermissions(@user)?@user=’i%3A0%23%2Ew%7Ccontoso%5Cbrianc’​

​Over next few months I will be sharing few more blog posts on REST API HOW TO Series.

Cheers.