SOLVED

Cannot create list or add site column using PNP PowerShell

Copper Contributor

Hi,

 

I have a development tenant where I am SharePoint Administrator. 

I want to create some site columns, content types and lists, on a specific site, so I am using PnP PowerShell.

When I run the command 

  • New-PnPList -Title testList -Template GenericList

I get the following error

duarte_Aguiar_0-1669308978316.png

I'm a site collection administrator, but SharePoint won't assume my permissions.

I have tried the same actions on 2 other development tenants and a production tenant and I can perform the actions I want, this issue only occurs on this particular office 365 developer tenant. 

 

PowerShell Code:

  • Connect-PnPOnline -Url {SITEURL}
  • $web = Get-PnPWeb
  • $currentUser = $web.CurrentUser
  • $web.Context.Load($currentUser)
  • $web.Context.ExecuteQuery()
  • $web
    $currentUser
    $currentUser.IsSiteAdmin
  • New-PnPList -Title testList -Template GenericList

output:

duarte_Aguiar_1-1669309429136.png

Bellow I show some images confirming my statements.

duarte_Aguiar_2-1669309533108.pngduarte_Aguiar_3-1669309596113.png

 

 

5 Replies
I'm guessing you are using legacy auth,

try this:

Connect-PnPOnline -Url "YourSite" -Interactive
New-PnPList -Title testList -Template GenericList

@NicolasKheirallahI had already tried your solution and even so I can't carry out the creation, on this site, from this specific development tenant. In others I can

Have you tried in another site? does it work there?
I tried on 3 or 4 different sites in this tenant and I couldn't do this action using PowerShell, even on a new site, created from scratch for this test. After that I tried it on 2 different tenants and it worked
best response confirmed by duarte_Aguiar (Copper Contributor)
Solution

Hi everyone, I asked this question on another forum and using Connect-PnPOnline -Url{site url} -UseWebLogin I was able to do the creations.
Thank you very much

1 best response

Accepted Solutions
best response confirmed by duarte_Aguiar (Copper Contributor)
Solution

Hi everyone, I asked this question on another forum and using Connect-PnPOnline -Url{site url} -UseWebLogin I was able to do the creations.
Thank you very much

View solution in original post