Forum Discussion
omkar kuchekar
May 19, 2017Copper Contributor
How to export XML from sharepoitn site using PnP provisioning schema.
Hi all, I am posting some basic info regarding how we can retreive XML from sharepoitn site using PnP provisioning. It helps to start the basic of sharepoint PnP provisioning schema.It might be h...
Anonymous
May 19, 2017Why do you not use the Powershell commands?
Connect-PnPOnline -Url $Site -Credential 'nltest'
Write-Output "Context obtained";
Get-PnPProvisioningTemplate -Force -Out C:\temp\nltest.xml
omkar kuchekar
May 19, 2017Copper Contributor
Its a secure machine so I dont have any software installed so that i am using sharepoint online ans VS2015 to communicate sharepoitn site.Thanks for the info.
- May 19, 2017
Hi omkar kuchekar,
Being a secure machine or not doesn't make sense. If you can run a console app ( that you are building then you could copy the Powershell module folder form a different system.
set $env:PSModulePath to include that folder and PowerShell will pickup your PnP PowerShell. The PowerShell CmdLts don't do anything else than a Console app would do.
If you're just trying to export templates then I would agree with Deleted PnP PowerShell is the easiest option.
- AnonymousMay 19, 2017
have you tried this example?
private static ProvisioningTemplate GetProvisioningTemplate(ConsoleColor defaultForeground, string webUrl, string userName, SecureString pwd) { using (var ctx = new ClientContext(webUrl)) { // ctx.Credentials = new NetworkCredentials(userName, pwd); ctx.Credentials = new SharePointOnlineCredentials(userName, pwd); ctx.RequestTimeout = Timeout.Infinite; // Just to output the site details Web web = ctx.Web; ctx.Load(web, w => w.Title); ctx.ExecuteQueryRetry(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Your site title is:" + ctx.Web.Title); Console.ForegroundColor = defaultForeground; ProvisioningTemplateCreationInformation ptci = new ProvisioningTemplateCreationInformation(ctx.Web); // Create FileSystemConnector to store a temporary copy of the template ptci.FileConnector = new FileSystemConnector(@"c:\temp\pnpprovisioningdemo", ""); ptci.PersistComposedLookFiles = true; ptci.ProgressDelegate = delegate(String message, Int32 progress, Int32 total) { // Only to output progress for console UI Console.WriteLine("{0:00}/{1:00} - {2}", progress, total, message); }; // Execute actual extraction of the template ProvisioningTemplate template = ctx.Web.GetProvisioningTemplate(ptci); // We can serialize this template to save and reuse it // Optional step XMLTemplateProvider provider = new XMLFileSystemTemplateProvider(@"c:\temp\pnpprovisioningdemo", ""); provider.SaveAs(template, "PnPProvisioningDemo.xml"); return template; } }