Created
May 16, 2016 11:09
-
-
Save sksnips/b16c9fbedb57ea4a15f3afee61f6ad3e to your computer and use it in GitHub Desktop.
This code snippet returns the collection of all the URLs of web sites from the Site Collection including top level site and its sub-sites using CSOM PnP Core Component.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author: Shantha Kumar T | |
//Assembly Reference Used: OfficeDevPnP.Core, Version=2.4.1605.0, Culture=neutral, PublicKeyToken=3751622786b357c2 | |
//Supports: SharePoint Online, SharePoint 2013+ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Microsoft.SharePoint.Client; | |
using OfficeDevPnP.Core; | |
namespace SampleApplication | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string siteUrl = "https://sharepointonline.sharepoint.com"; | |
AuthenticationManager authManager = new AuthenticationManager(); | |
//Interactive Login to SharePoint site - Opens a Online signin page to authenticate the user | |
var context = authManager.GetWebLoginClientContext(siteUrl); | |
IEnumerable<string> webUrls= context.Site.GetAllWebUrls(); | |
string weburl = ""; | |
foreach(var url in webUrls) | |
{ | |
weburl += url + "\r\n"; | |
} | |
Console.WriteLine(weburl); | |
Console.WriteLine("Press any key to exit."); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment