0

I was wondering if anyone knew how to Hide the Default Title Column when you create a new List using the Powershell Sharepoint PNP Module.

I've been trying the following

    $field = get-pnpfield -Identity "Title" -List "Lists/Services" -Web /
    $field.Sealed = $false
    $field.Hidden = $true
    $field.Required = $false
    $field.SetShowInDisplayForm($false)
    $field.SetShowInEditForm($false)
    $field.SetShowInNewForm($false)
    $field.update()

However the Title Column is still present when I reload the list.

I can remove manually by going into each List, enabling Content Types; Then hiding the column and removing it from the list view. But I plan to move 20+ excel workbooks onto sharepoint and I don't want to do it manually for each sheet/list in the workbook.

2

With PnP Powershell, after you have hidden the title field and executed $field.update(), you also have to execute

 $field.Context.ExecuteQuery()   or  Invoke-PnPQuery

This will push the updates to your field

  • Thanks, the Invoke-PnPQuery really helped.... the only issue is I can't tell what I changed because I was mucking around. Ended up changing/deleting the fields "Title" and "LinkTitle" as well as trying to adjust the View. Not sure which ones worked but its finally gone. – Shadowzee Oct 31 '18 at 4:00
1

Run Set-PnPField

Set-PnPField -List '<listTitle>' -Identity '<ColumnName>' -Values @{Required=$false;Hidden=$true}

If the field is hidden, it will not display in the forms, so we don't need to set "SetShowInDisplayForm($false); SetShowInEditForm($false); SetShowInNewForm($false)".

PnP does not provide method to set field displayed in the list. As a workaround, create a new view and add fields using Add-PnPView, then remove the old view using Remove-PnPView.

If you don't want "Title" field any more, you can remove it from the list using Remove-PnPField.

Remove-PnPField -List "<list>" -Identity "Title"
0

Make sure you have Shell access role or you can add yourself as a shell admin .

ADD-SPSHellAdmin . It will ask for username ,enter your name .

After this you need to add PSSnapin.

Add-PSsnapin "Microsoft.SharePoint.PowerShell".

Only then will you be able to run Get-SPweb command. Try using below snippet:

$web = Get-SPWeb -Identity 
'http://www.spsite.com/subsite'
$List = $web.Lists['MyList']
$column = $List.Fields.GetFieldByInternalName('Title')
$column.Hidden = $true
$column.ShowInDisplayForm = $false
$column.ShowInViewForms = $false
$column.ShowInEditForm = $false
$column.ShowInListSettings = $false
$column.Update()

# To delete the column, simply add the following row
$List.Fields.Delete($column)
  • How do I get access to the Get-SPWeb Command? I can't install Sharepoint-server module on my desktop and I was hoping to keep it purely within the sharepoint-pnp module. – Shadowzee Oct 31 '18 at 2:45
  • For getting access to Get-SPweb two things that are necessary. One you should have shell access role on the database of the webapplication that you want to query using Get-SPweb. Second thing you will need to add PSSnapin like this. ADD-PSSnapin "Microsoft.SharePoint.PowerShell" . The code written by Ganesh above fails if you do not have this 2 things ticked. – yash.kamdar Oct 31 '18 at 7:01

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.