I am building a site creation script in PowerShell working good for now.
I added a part to create lists and add to navigation depending on what kind of site is selected.
`
Connect-PnPOnline -Url $NewSiteUrl -Credentials $cred
New-PnPList -Title Newsfeed -Template DiscussionBoard
New-PnPList -Title Tasks -Template Tasks
New-PnPList -Title Contacts -Template Contacts
New-PnPList -Title Calendar -Template Events
New-PnPList -Title Links -Template Links
Add-PnPNavigationNode -Title "Newsfeed" -Url "$NewSiteUrl/Lists/Newsfeed" -Location "QuickLaunch"
Add-PnPNavigationNode -Title "Tasks" -Url "$NewSiteUrl/Lists/Tasks" -Location "QuickLaunch"
Add-PnPNavigationNode -Title "Contacts" -Url "$NewSiteUrl/Lists/Contacts" -Location "QuickLaunch"
Add-PnPNavigationNode -Title "Calendar" -Url "$NewSiteUrl/Lists/Calendar" -Location "QuickLaunch"
Add-PnPNavigationNode -Title "Links" -Url "$NewSiteUrl/Lists/Links" -Location "QuickLaunch"
Add-PnPNavigationNode -Title "Manage Site Access" -Url "$NewSiteUrl/_layouts/groups.aspx" -Location "QuickLaunch"
` While the script runs I get this error when it goes through this section:
format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. + CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException + FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatDefaultCommand
When the script stops, if I go back and select the code and run Selection in PowerShell it will go ahead (sometimes) and create all the list and add them to the navigation.
I tried putting each line into a variable and calling it, also tried to put a start-sleep 15 between each library creation but it errors out still.