Forum Discussion
Site Scripting creating new lists every time
Rob EllisNo, I'm working on adding columns and views so as I add them I rerun this script to update the script stored in the tenant. Maybe it makes a difference if I delete the site design and re-add it rather than just updating the script?
$siteScriptId = "<guid>"
$siteScriptFile = $PSScriptRoot + "\ConfigurePMOSite.json"
Connect-SPOService $adminSiteUrl -Credential $cred
Having now made the change to the script - if you run it on a brand new site, then run it a 2nd time - do you get the issue?
(Just trying to confirm whether the issue is the multiple runs, or the script change)
- Kevin_HoytApr 30, 2019Iron Contributor
Rob EllisI figured out what is going on. I am using the site script to create a new list but I was trying to be a good "old school" SharePoint developer and create the list name without any spaces. So when I was using the "CreateSPList" verb I was using something like "ListName" as the value for listName in the script command and then I was setting the title to "List Name" with a space in it as a subaction.
But if you do that and re-run the script it tries to find a list with a display name of "ListName" and there isn't one. So it creates a new list called "ListName" and a display name of "List Name". Because there is already a list called "ListName" it adds a number to the end of it and recreates it.
Does that make sense? Bottom line, I need to be okay creating lists and libraries with spaces in the internal name (my inner SharePoint developer self is cringing at that comment).
- Rob EllisApr 30, 2019Bronze Contributoraha! So when I originally asked 'Has the display name of your list been changed since creation?' - you actually meant yes, right? :-)
- Kevin_HoytApr 30, 2019Iron Contributor
Rob Ellis<sheepish grin>