Console Application Using PNP (Patterns and Practices) – SharePoint Office 365

Sathish Nadarajan
SharePoint MVP
Published On :   16 Jul 2016
Visit Count
Today :  3    Total :   6320

In the previous article, we had seen, how to create a console application against a SharePoint Office 365 Site using the Client Side Object Model. In this article, let us see, how to create the same thing using Patterns and Practices (Office Core Dev PNP).

1. Create a new Console Application using Visual Studio 2015.


2. Add the NuGet Package SharePointPNPCoreOnline


3. Once, we install, the solution will look like below.


4. Now, let us go to Program.cs. Add the below code on Program.cs

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using Microsoft.SharePoint.Client;
 namespace Provisioning.Console
     class Program
         static void Main(string[] args)
             OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
             string siteURL = "";
             string userName = "";
             string password = "************";
             using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))

5. Execute the program. We will get the Web Title.

There are much more Scenarios where PNP plays a crucial role. Let us try to cover one by one on future articles. There are many Extension methods available.

Happy Coding,

Sathish Nadarajan.