2

Title is a default column that comes with a generic list which I want to remove. Any idea how to make this work?

Pnp:

 # CREATE NEW LIST
 $22 = New-PnPList `
         -Title 'Honours' `
         -Template GenericList `
         -Url lists/honours


# TODO: REMOVE TITLE
$99 = Remove-PnPField `
        -List 'Honours' `
        -Identity 'Title' `
        -Force

Error:

Remove-PnPField : Operation is not valid due to the current state of the object.
At line:2 char:7
2

I am able to reproduce the issue and I tried different approaches as well but not able to delete the column.

As a workaround, you can hide the Title column. Below is the script for the same. it will first make the Title column not required and then hide it.

Connect-PnPOnline https://contos.com/sites/Test
$context = Get-PnPContext
$web = $context.web
$list = $web.Lists.GetByTitle("Honours")
$context.Load($web)
$context.Load($list)
$context.Load($list.Fields)
$context.ExecuteQuery()

$field = $list.Fields.GetByInternalNameOrTitle("Title");
$context.Load($field)
$field.Required = $false
$field.Hidden = $true
$field.Update()

$context.ExecuteQuery()
  • I actually love you!!!! <3 – BennKingy Nov 28 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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