Last active
September 26, 2019 10:17
-
-
Save gautamdsheth/18b21fa5eab65d1e13d6480dfcaeb2b3 to your computer and use it in GitHub Desktop.
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
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