Modern SharePoint Site Provisioning using PnP Provisioning Engine | PnP PowerShell

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome back to our youtube channel ds tech middle topic for today video is pnp provisioning in modern sharepoint in this video we'll learn the basic concepts of pnp provisioning and then using pnp framework we will see how we can create site template from existing sharepoint site using pnp powershell or in other words we will learn how we can automate site provisioning in modern sharepoint using pnp provisioning so let's get started i'll start with the introduction of the pnp provisioning what is pnp provisioning pnp provisioning is used to automate site provisioning in sharepoint online it's a method in which what we can do we can create a site manually what we can do we can create all the site columns content type we can create our home page we can deploy all the spfx component we want to deploy on that particular site kind it's like we can manually create one side which we want to use as a template for other sites and then using pnp powershell we can export the pnp template of that particular site which later can be reused to apply to target sites so this is the overall idea of the pnp provisioning engine in other words for every site we have pnp template if you have sharepoint site we can download its pnp template how our pnp template will look like that i will show you after some time as we will proceed with other slides i will show you how a pnp template will look like what all other things we can you know automate or we can provision using pnp provisioning because in my last video we saw how we can do site provisioning using site designs and site scripts but there were certain limitations with that site design and site script one such limitation was that using site design and site script what it will do it can deploy the spfx component in our site but it is not going to add into the pages for example let's say i have one spfx web part added to my home page now if i am doing site provisioning using site design and site script so what it will do it will install that spfx web part in my site but it will not add that web part on my home page but if i do site provisioning using pnp provisioning then that limitations will overcome we will overcome almost all the limitations which we have in site design and site script another important point is site designs and site script are only available for sharepoint online whereas this pnp provisioning engine is available for both sharepoint online and sharepoint on-premise coming back to the second point pnp provisioning can be used to move artifacts from test to staging to production environment because this is a very common scenario where we will do all our development on there you know we'll try whenever we get any requirement from the client we start from the development environment now how we can take our sites or how we can take our change changes from the development to the staging and from staging to the production environment the best and the you can say easiest approach is the pnp provisioning now just now i said like every site we can you know has pnp template and we can export it so uh now so by now you must have understood that we have some pnp templates for sharepoint sites but in pnp we have another template called tanning template so tenant template will be out of scope for this video but i'll just give you the basic definition that tenant template has the ability to provision artifacts beyond sharepoint sites because as the word is saying template if you want to do perform any provisioning or perform any action using pnp that is outside the scope of sharepoint for example msteam powerapps ms flow for that you have to use standing templates of pnp provisioning engine but in today's video i will cover only site template of the pnp provisioning engine so that was the basic introduction now next question would be how you can export the pnp template so there are certain powershell and these are pnp powershell that we will we will run this pnp powershell in sharepoint online management shell first of all and using this pnp powershell we are going to export the pnp template another thing is we can also use csum that is a c c sub model client side object model using c sharp we can export the pnp template we can apply the pnp template by creating simple console application but that i will cover in my next video in today's video we will see how we can perform the entire provisioning approach entire provisioning method using powershell so these are the below commands so what i'll do instead of you know taking you through this slides uh slide with along with the slides i'll start with the demo also so let me go to my browser so you can see i have one source side with me now what i will do i am going to export the pnp template of this particular site and i will apply that pnp template on this destination site so this is one destination site this is a blank site this is a blank team site without office 365 without office 365 group and this is one source side modern team site without office 365 groups so in this you can see we have application customizer at the top that is header and footer in my home page i am one spfx web part i have few out of the box web parts now if i come under site contents over here i can see i have site assets library i have other custom lists as well database list first fc list formatting all these are custom list these are my spfx component which is installed in my site and a few are added on my home page and if you are headed across the site like application customizer it is available on all the pages my spfx webpart is added on home page apart from that if i go to site settings and if i go to site content types so i have some custom content types test city you can see that and i have another content type over here it is it is also a custom content type finance so in this site i have some custom content types i have my home page i have spfx component i have sharepoint groups so all these are already present so now what i will do i will export the pnp of this particular site using pnp powershell so now to begin with there are certain you know points over here i mentioned so you know in my system pnp sharepoint pnp framework is already installed so what i'll say to explain you first of all what you should do because this pnp is an open source so it's keep getting evolved the you know earlier version will keep getting deprecated the new version will keep getting introduced and they will be you know changing the commands so right now you could see this one command over here get pnp site templates earlier you know it was a different command it was like get pnp provisioning template like that so if you want to run these commands which i am showing on my ppt and this is these are the latest one these are the recommended one which you should use so you have to perform some prerequisite for that now if you are you know running this pnp powershell for the first time in your system what you can do whether you have already installed it or it's you have not used it i would say run this first command uninstall module name sharepoint pnp powershell online so all version sports if any of the pnp powershell version is installed in your system it would get uninstalled in my system so i have already done that so i cannot run this command again now then i would say run install module name pnp dot powershell so what this pnp community have done earlier there was pnp core for that we have to use sharepoint pnp powershell online now they have depleted that they have archived that so and they have introduced a new pnp library called pnp framework now to use pnp framework and its commands what we have to do we have to install module pnp dot powershell so you install that and after that you have to run this command register pnp management shell access so it will get register in your tenant so it will ask your consent on few steps just do that and after that your system would be ready to use pnp online powershell commands and then after that you can start working with the pnp powershell and for that we would be using sharepoint online management shell let me mention it over here sharepoint online management shell if you are working with the sharepoint online now so what i will do the first step or the first command is connect pnp online since i have to export the pnp template of the source site so first of all i have to connect to the source because another because the comma the actual command for exporting the template is get pnp site template if i directly you know start exporting the template it would give me an error because the authentication is not established between my management shell and the my site so let's start with the uh let's first establish the connection so i'll say connect pnp online and over here as i mentioned site url not admin center we have to give the site url if you give the you know admin center url then you know it will start exporting the pnp of that particular admin center so let's start this is sharepoint online management shell i'll say connect pnp online and then i'll copy the site name and then i'll press enter now it is asking me for the credentials i will provide the credentials then the password and now you can see the connection is established now i can run my command to export the template the command to export the template is get pnp site template hyphen out pnp provisioning file.xml so i will explain you what it is this is my command that is get pnp site template and okay get pnp site template and hyphen out parameter will say that it will export the pnp file with this particular name and at this location in which your management shell is running so the moment i paste this command you can see extracting template for this particular site so extraction process already begin and i can i can found my template that is pnp this dot xml file at this particular location so if you want to generate your template and any other location you can provide the full path in this out parameter or you can run your management shell from that particular directory directory another important point is pnp site template comes with two extension you can run this dot xml or you can also use dot pnp so both are supported and i over here you can see pnp template can be saved saved as dot xml or pnp the only difference is if you will you know extract using dot xml if you will run this pnp template as dot xml so what it will do because uh we have to include the branding features as well now there would be site logo and there could be other assets also for that it will you know download all the files and it will create a folder called site assets inside that it will download everything now if you will save it as dot pnp so inside that pnp package it will download everything it will not create a separate folder for that what you can do you can rename dot pnp and you can see it as dot zip and then if you will double click on dot zip you could see all the assets inside that so i'll show you in a moment but before that over here you can see our template got downloaded let me go back and this is my pnp template pnp provisioning file.xml and let me open in a notepad so this is how my pnp xml file or pnp template of a site will look like over here you can see pnp provisioning this is the schema url template pnp provisioning template name version number basic site template this means stream site this is a root site then there are certain handlers with that one is the web settings inside web settings it will store all the information request access url no crawl welcome page site logo and everything it got you know all the information got stored over here you can see site logo is blank so it it's not gonna you know export the site logo at today's destination or you can say it's so you can say it has not exported the site logo why it has not done we'll see site settings all the security it means all the groups their members navigation my global navigation my site fields my content types so i you know i show you certain content type that is one of these one of the example is finance test city all the custom content type it already exported all my list got exported their views all the site columns list columns then their views everything over there we can see fields if any is break that is also you know uh that information also got exported so this is very very powerful as compared to site design and site script it is much more powerful all the fields and you can see it's a it's a very big it's a huge template that got exported content type bindings are there views are there property back entries my choice fields and if i scroll down over here you can see my choice column my application custom actions are also got exported the features so everything got exported over here now important point over here you can see there is no information about the site logo so by default it will not include the branding information for that we have to provide one parameter explicitly then only it will export that so let me mention that one door slide slide also or you know i'll show you first first of all let's go to the source side this is our source site and let's change the logo what i will do change the look i have to change the theme also i use this dark theme dark yellow this is fine then i have to change the logo side information change i'll see use the site logo the stack mirror and see so over here you can see i have the site logo and side theme also now what i will do i'll go back to my powershell and let me include one more parameter i will say persist and i'll press tab you can see persist branding files so i have to explicitly mention this parameter another point is if in your site there are multiple pages on the site pages so by default it will not include all the site pages if you want to include all the pages you have to include another parameter will say include so you can say site collection site groups term group all these are explicit settings which you have to mention over here include all pages and persist blending files in my site there are no pages but let me mention these two important points and let me add that in the slides to include branding and all pages by default these are not exported and i mentioned both the both the parameters over here so this is fine now i have my uh you can say i have my logo and site theme i've applied let's do one thing i am in the directory and let me delete this xml just to you know avoid any confusion now i'll run this again this time i'll press enter and now you can see it is you know uh it is processing with each handler initially it started with web settings audit settings and now it is extracting fields and after phrase it will export other features over here you can see it is processing now content type extraction begin list instances so this is one database list which i have so all all the features of the site can get exported now in any scenario if any of the feature got missed out so annually you can add that in your exported pnp and then you can use that to apply it to the you know sites or reuse it now it is processing with site pages spfx assets spfx custom form these are the list all these are list in my source site so i'll wait for the extraction to finish now it is exporting all the client side pages because explicitly i have mentioned over here so this is done now my template is ready let's go and i'll try to okay it is already open in my notepad and it will ask me to reload and it's fine now first thing i want to show you over here is the site logo now my site logo is not blank over here you can see i have the information about my site logo and where it is downloaded in the same directory it created a folder called site assets and inside this i have this site logo which it will use to apply to the sites so this is one feature now another very important thing by default site theme it is not extracting actually i tried everything from my end but i didn't find any reason why it is not exporting the site theme so manually i will you know include the site theme over here also i will mention include site theme manually and what is the command for that i will mention it over here so i am over here so just above this web settings what you can do you can say pnp and then theme and over here you have to mention the name and another parameter is inverted and another parameter is inverted so let me copy paste that line over here this is my line so pnp theme name is dark yellow is inverted is false so and i will paste the same command in my pd also over here because it is very important to document everything it would help you and let me just reduce my font size just to include everything yes fine so guys this is about my export pnp template so my exported pnp template is now ready i will save it now this template is ready now i have to see how i can apply the pnp template so again applying pnp template is very simple just connect with your pnp site alright sorry just connect with your site using connect pnp online and then use command invoke pnp tenant template and over here this command is wrong from my end it is invoke pnp site template and the path you have to mention where your template is stored so let's start applying the pnp template before that one point again i you know i want to highlight is make sure that pnp dot powershell is installed in your system this module is installed and not sharepoint pnp powershell online otherwise these commands would not match because in pnp code this command was apply pnp provisioning template so it got completely changed and pnp got archive pnp community is not going to update that library now so it is recommended to use pnp framework that is pnp dot powershell module so i just want to highlight that point again because it is very important so now i'll go back to sharepoint online management shell i'll connect my site pnp online and i'll mention the url over here this is my destination site you can see this is a complete blank site there are no custom list in this site only three four list our home page is totally different logo is different no side theme nothing so i'll connect to this particular site first and i'll press enter now i will enter my credentials so now i'm connected to my destination site let me you know apply the template now which we have exported using invoke pnp site template so this is my command invoke pnp site template hyphen path so i'm already in the same directory in which my template is stored so i will simply change the name over here this is my directory and this is the name of my file so i copy from here i will paste it over here and i will run the command as it is invoke and now over here i am getting one error okay because there is a difference over here in path i have this leading space so now there are no one more space at the end so just make sure there should be no space in your path so let's see whether this error is in my command or it is present in my template so it is saying at line one character line six position thirteen so let me let me try to open it again line six this is the same line which i have you know included so there could be there would be some error over here only so let me see quickly see and what is the error character hexadecimal cannot be included in a name okay so let me see what is the error so this time i have typed the line manually and let's see whether it will work because i don't see any error over here and now it's working so uh why and you know it's giving you an error what i can understand because while copying pasting maybe internally some encoding of character there could be some issue of like that because is the same code or is the same xml you can see it just i have typed manually so again uh this is not something you know documented anywhere it just based on my experience i'll say type manually in xml so just based on my experience i'll say time manually because you know i face this issue and you know while site designs also i face this issue when we copy paste so it would be good if you're adding something just type manually and let's go back to management shell and you know template uh its application setting up of the template on the target site it is in progress over here you can see this instances learning it is in progress so let's do one thing let's go to the target site let's refresh it and see whether we can see any changes not yet but we can see list formation is in progress let's creation is done so if i go over here i can see this instances spfx it is creating and all other lists which it already created i can see this list over here so as i said it created this list called uh spfx i can see this because it was present at the source it created again i can see this learning list it got created all these lists were present at the source and my pnp template or my pnp powershell it applied it in the destination also another important point is it will only you know export your schema of the list it will not export the list item because as per pnp community they are not you know working to prepare a migration tool they are just focused focus on you know creating the scheme of the site so you will not get the items so over here you can see all the items are zero in fact in my source also there are no items but pnp is not going to export and import your items it will just export an import of the list schema and other you know handlers of the site which is supported i will share the total i think there are total 30 handlers which are supported by pnp provisioning and i will in my you know uh other slides in my coming slides i will share that list with you but before that let's see let's wait for this process to get completed that is the importing of all the pnp pnp template into the target side so go back to management shell it is still in progress i can see it is creating list column for list database let me i mean this list called database and it's creating other columns if i'll go to list settings now it moved to another field it moved to content type so i could see all the columns because these many columns are present in my source also earlier this list was also not present so as soon as the changes got applied immediately we can see it in the target that is in the destination and in our case the url is the destination site okay now come back for now we have to wait for uh this process to get complete and then only will proceed since it is taking more time so what i'm doing i'm just pausing the video and the moment it will get complete so i'll resume from here and then we'll see other other information about this pnp provisioning and also we'll see how our target site is looking whether it apply the site theme whether it apply the site logo so for now i'll pause my video so over here that process is completed my applying pnp site template on the target site is completed over here you could see one error access denied you do not have permission to perform this section or access this resource now this is because of this warning list instance style libraries style library of a site with no script enabled and will be skipped so you can also ignore this error if you will encounter this error and if you want to overcome this error it just you have to enable no script on the style library with the help of a command that i will share with you so for now we can ignore this and let's go to the target site so this is my target site uh let me refresh it and see whether the changes are applied and what i can see my site logo got applied i can see all my uh application customizer i can see this my uh home page is ready it added all the web parts over here it created all the sites i i'll go into the site contents inside site contents i can see all my list formatting everywhere now if i'll go to content types if i go to site content site you can see custom content type there was one more content type called finance that is also created over here so i can see all the information that was present at the source got applied at the destination the only thing which is left is my theme i can see the theme did not apply over here so let's see what is the reason for that and then we'll try so for that let's go to my this pnp template and i can see over here i you know everything is fine over here dark yellow was the theme and the same was applied on the source also let me see over here if i'll go over here and say change the look theme so dark yellow is present but it it did not apply so right now what i can do if i want to you know run you know if any of the settings got missed and if you want to run this xml again so what i will do for now i will just run this pnp theme code and i will i will remove the other settings so over here what i will do let me go over here and i will say from still here i will remove everything and what i have pnp provision template and inside this i have my theme tag over here pnp theme name dark yellow and i'll try to run this again so i'll say invoke because i'm already connected to this target site so i need not to you know reconnect to the site again the connection will persist until unless i close this sharepoint online management cell so let me run again and this time it will not take much time because it's just the theme so it got completed and let's see and this time it got applied i'm also not sure why it did not get applied at the first bridge it should but in case if you face the same issue what you can do uh you can run that piece separately or or otherwise we will see you can see also see at your end it should run and it will run when you will run the entire code again so it will run so for now let's move forward so over here you you saw like my entire site got replicated so this is how you can provide in your site what you can do you can extract your pnp template you can keep it in one site directory in one folder you can just you have to just these two line connect pnp online and invoke pnp site template you have to just run this powershell and you can provision your site automatically other thing in my next video what i will do i will show you how we can do the same process using console application and if you want to you know overcome this manual step then we can run you know we can schedule that console application using task editor that is also we can do so this is how we can automate this process as well now coming back to the ppt so our demo is over now i'll cover the other other important aspects of the pnp template now i have export selective artifacts which i just showed you now if i don't want to you know export all the artifacts of the site if i want to export certain artifacts let's say i just want the pnp of one particular list i want pnp of just one content type how i can do that for that what i have to do i have to give one parameter called configuration and then i have to give one json file called config.json in that json file i will mention what all artifacts i want to export and then i can export that selective artifact so let's see how that json file will look like so this is how my json file will look like so these are the parameters which will remain constant only these things will change now what are these handlers in handlers i'm saying i just want list and inside list i'm mentioning i want list with title youtube content if i want multiple lists i will there will be comma separated multiple list and i can download them and i was saying i will supply the entire list of the handlers so this is the and handler supported by pnp framework again not sharepoint online on not pnp core but by pnp framework so what all is exported and imported using this pnp provisioning audit settings composed look your branding which we saw custom actions we saw features we saw extensibility providers fields file list pages ui languages publishing regional settings search settings site policy taxonomy workflow site security content type almost everything property back web settings navigation image retentions tenant web api side header footer theme site setting so almost it is covering everything so it is really really very powerful coming back to the demo so demo we have already saw just i'll show you one thing how we can you know export the selective artifacts for what i'll do i'll simply use this schema so i'll copy it i'll go to the directory this is my directory i'll go to video this is my directory over here i'll say new file i'll say config.json and i'll save it now you must be wondering how you will include the other handlers so what i will do pnp team has provided the entire schema how you can create this config file i will share that link with you it is present in the ppt and is also present in the description box below so you can go from there and with the help of that you can create this schema i did that only so first let's see how we can use this config file so now config file is ready with me this is my config file i'll go to my ppt file what i will do i will again connect to the source side or what we can do since we want to export the just one list instead of you know reconnecting again to the source i use the destination site itself and i'll export this list so because youtube content is available in my destination also so let's see so this is my destination and i can see this list is present so let me run this powershell or pnp powershell i should say so this is my command get pnp site template configuration config.json and out is only list template.xml so i'm in my management shell i'm running cls just to clear this screen and enter so now so over here right now it is not working so over here i can see it is exporting everything i can see fields everything so what i'll do i'll say control c and i'll stop this process and let's see what is the error first of all we'll fix the error and then we'll you know proceed so friend this is my config.json file and why we are getting this error because there is one space at the bottom so we have to take care of such things in the configuration file and in my pnp template as well so i'll show you it is still giving me an error so if i run this command again so command is same get pnp site template i provided the configuration file we are in the same directory and out that is out is the name of my template file which it will generate so if i'll run again so you can see it is not considering this configuration file and it starts exporting everything so i'll press ctrl c just to stop this process now i'll remove the space control s this is my same config file i'll close my notepad and i'll run again let's wait and over here okay it is still giving me an error let me go back to my config file again this is my config file and there could be some other space let me remove any any any spaces these are my lists i save and let me try to run it again and over here you can see it is generating list instance and only youtube content so now it is not exporting each and everything so just just be careful they should end you you can you can also observe that it got finished very quickly because it has to export only one list so important point is make sure there are no extra species in your config.json file because otherwise it will give you unnecessary trouble now let's go back to my folder and this is my template only list template.xml and you can you can see the difference it's a small file it will it has no information about web settings about content type it has only information about list list instance that is only youtube content content type binding for this particular list views information about this list this list fields and that's it it has you know one choice column that you know what i'll do let me quickly show you just to give you you know make sure that it exported the correct file this is the some you know issue with my application customizer which is troubling me so i will avoid it for now because that would be the outside of the scope so let's go to list settings and i have to show you choice columns over here you can see status is my choice column and if i come over here field displaying status so this is done so it is generating correctly another another thing how you are going to prepare this config file so i have shared the url with you over here and one of the slide i think in configuration file this is the configuration file schema will use that it is already open with me i will quickly explain it so over here you can see this is the complete schema they have tried to explain each and everything so if you want to include asset file you have to use this particular property and its description they have given type multi-language publishing it will come down some tenant if you want some tenant properties if you want to export if you are working with teams pages so the entire information is provided here list of all the handlers is provided at the bottom and such setting site footer so now let's say if you want to include only a site footer so just do one thing go at the top include this basic information about this schema then mention the title mention the version number description and then after that start with the site footer just type this site footer and you can say type is object so we'll start with curly braces additional properties say false properties properties that remove existing nodes so description so inside site footer will mention remove existing node and i will provide the value true or false this is how it's gonna work like navigation and type is object properties that remove existing nodes it's the same for the navigation also and if i come under search settings so i'll say search settings description it it is saying like it will define your search settings type is object only and properties are include so i'll say search settings and inside that i'll type include column true now to explain it better i'll search list and you can see the description of the list is given over here and how i prepared my schema using this description so this is my description for the list what i did schema title version description that is that's it now i have i'll share the handlers so handler what i want i want only list if i want something extra i will mention it over here then i came under list i type list inside that it is saying list settings fine object i started with the braces and additional properties fall include hidden list i don't want to do another property i saw i saw list i started with another property it said description it said type is added i created an array over here and inside this property i can see it is saying title and then include items then key column so i said i don't want anything i want only title so guys this is how i created this config file so now i've shared the link of the configuration schema with you so with the help of that schema and this sample file you can create your own configuration file and you can you know export the limited artifacts if you want let's go back to the ppt so this is my configuration files handlers are already covered and demo is also already covered so with this we reach to an end of this video if you like this video please like and share the video and subscribe to the channel to get notification for our upcoming videos i have created a group over facebook called modern sharepoint link is in the description box below if you want you can join that group you can also follow me on twitter this is my twitter handle to get all the updates from the office 365 world till our next video much love keep learning thank you
Info
Channel: DS TechMirror
Views: 2,097
Rating: 5 out of 5
Keywords: sharepoint, pnp, PnP Provisioning, modern sharepoint, SharePoint site provisioning, pnp powershell, pnp provisioning engine
Id: FWf_b_MxF2Y
Channel Id: undefined
Length: 40min 53sec (2453 seconds)
Published: Fri Apr 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.