Skip to content

Instantly share code, notes, and snippets.

@gautamdsheth
Last active April 17, 2020 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gautamdsheth/6cd4a8131a8606eb075ed89915e7c93e to your computer and use it in GitHub Desktop.
Save gautamdsheth/6cd4a8131a8606eb075ed89915e7c93e 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 template page
ClientSidePage page = clientContext.Web.LoadClientSidePage("Template/IT_Template.aspx");
// Create and Save the modern page based on the template
page.Save("IT_Australia.aspx");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment