Skip to content

Instantly share code, notes, and snippets.

@gautamdsheth
Last active September 26, 2019 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gautamdsheth/18b21fa5eab65d1e13d6480dfcaeb2b3 to your computer and use it in GitHub Desktop.
Save gautamdsheth/18b21fa5eab65d1e13d6480dfcaeb2b3 to your computer and use it in GitHub Desktop.
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using ClientSidePage = OfficeDevPnP.Core.Pages.ClientSidePage;
namespace ConsoleApp1
{
class p3
{
static void Main(string[] args)
{
string userName = "username";
string password = "password";
using (ClientContext clientContext = new ClientContext("https://<your-site-url>"))
{
SecureString securePassword = new SecureString();
foreach (char c in password.ToCharArray())
{
securePassword.AppendChar(c);
}
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
// Load the page
ClientSidePage page = clientContext.Web.LoadClientSidePage("IT.aspx");
// Save the page as template for later use
page.SaveAsTemplate("IT_Template.aspx");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment