0

I want to create 7 SharePoint lists and Fields in SharePoint online using a PowerShell script.

In XML I have mentioned the list names and Field Names with Field Types.

How to call this XML file to Create lists and Fields in SharePoint Online one by one, using PowerShell?

Can you please anyone share the sample PowerShell script to read the XML values in PowerShell?

Or suggest me some other way instead of calling XML file to create bulk list and fields.

1 Answer 1

1

First, Read XML file

 $Listfile = Get-Content Lists.xml

Second, Based on your XML keys structure, perform nested loop for the list and its fields

foreach( $list in $Listfile.Lists) 
{ 

  # create your list using PnP
   foreach( $field in $Listfile.Lists.Fields) 
   { 
     #Use PnP to create fields
   }
}

Finally, at this link, you will find the cmdlets for CREATING LISTS AND FIELDS IN SHAREPOINT WITH PNP-POWERSHELL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.