Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Invoke-PnPSiteScript #4468

Open
jh-sigmadx opened this issue Oct 22, 2024 · 2 comments
Open

[BUG] Invoke-PnPSiteScript #4468

jh-sigmadx opened this issue Oct 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jh-sigmadx
Copy link

jh-sigmadx commented Oct 22, 2024

Reporting an Issue or Missing Feature

Running "Invoke-PnPSiteScript" on a site to Update the list there - does not update the list or add the additional column
In fact - the script exits complaining that the "List already Exists"
The script was run once to create the list from the json file.
The json file was then amended to include a brand new column (by extracting from an existing list again using: Get-PnPSiteScriptFromList -List $listName)
The script was then run again on the same site, but giving the output:

Expected behavior

I expect the List schema to be Updated, and the new column added, as per the documentation here:
https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-overview

This Documentation states:
"Site scripts can be run again on the same site after provisioning. Site scripts are non-destructive, so when they run again, they ensure that the site matches the configuration in the script.

For example, if the site already has a list with the same name that the site script is creating, the site script will only add missing fields to the existing list."

Actual behavior

The Output for the "CreateSPList" action is:

ErrorCode : -2130575342 Outcome : 2 OutcomeText : List with name TestList already exists. Target : TargetId : Title : Create or update list "TestList"

Steps to reproduce behavior

Export a List to a json definition using
Get-PnPSiteScriptFromList -List $listName > list.json
Create a new list using
Invoke-PnPSiteScript -Script list.json

Edit the List (manually) to add a new Column
Repeat the above process to update the list.json, and to update the existing list with the additional column

What is the version of the Cmdlet module you are running?

I have tried with both version 2.12 and the nightly build 2.99.2

Which operating system/environment are you running PnP PowerShell on?

Linux - Powershell version 7.4.4

@jh-sigmadx jh-sigmadx added the bug Something isn't working label Oct 22, 2024
@gautamdsheth
Copy link
Collaborator

hi @jh-sigmadx , this is not a bug.
This is a behavior of the site scripts functionality, not a bug.

Site scripts can't update existing lists.

You can consider using PnP Templates :

https://pnp.github.io/powershell/cmdlets/Get-PnPSiteTemplate.html

https://pnp.github.io/powershell/cmdlets/Invoke-PnPSiteTemplate.html

@gautamdsheth gautamdsheth closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
@jh-sigmadx
Copy link
Author

jh-sigmadx commented Oct 23, 2024 via email

@gautamdsheth gautamdsheth reopened this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants