how can I change read only to non read only content types and then delete using powershell and / or pnp RRS feed

  • Question

  • Hi,

    I have about 200 content types coming from a hub to the site collection I am working on. THey are all read only. How do I make them non read only and then delete them afterwards using pnp or regular powershell?

    I tried this and it didnt work:

    $ctlist = Get-PnpContentType foreach ($ctype in $ctList) { if ($ctype.Group -like "Teck*") { $ct = Get-PnpContentType $ctype $ct.ReadOnly = $false $ct.Update($true) Execute-PnpQuery }}

    Any suggestions would be appreciated

    • Edited by ldpozo Wednesday, April 24, 2019 9:20 PM
    • Moved by Bill_Stewart Wednesday, September 4, 2019 9:29 PM Off-topic
    Wednesday, April 24, 2019 9:18 PM

All replies

  • You have to have correct permissions on the files on SharePoint and then you need to use the "remove" command to delete the list items.

    Post in SharePoint forum for help using SharePoint.

    Also you code has some big syntax errors that need to be addressed.


    • Edited by jrv Wednesday, April 24, 2019 10:17 PM
    Wednesday, April 24, 2019 10:17 PM
  • See: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/remove-pnplistitem?view=sharepoint-ps

    You cannot just copy arbitrary code without any understanding of both SharePoint, SharePoint PnP and PowerShell.


    Wednesday, April 24, 2019 10:20 PM
  • First of all, the issue is regarding content types, not list items. Please understand the question first

    No I am not an expert but I understand sharepoint really well. Not a pnp expert as most financial clients wouldnt touch it hence my need for help. 

    Both of your responses were snide and wrong. Please dont respond again.

    Wednesday, April 24, 2019 10:29 PM
  • You need to understand how to use Pnp.  You also need to post correct code that is not all jammed together on one line.

    To remove a content type you need to use the correct commands.


    Again - post in SharePoint forum for help with how to use SharePoint and read the full documentation for the PnP module.

    Without understanding SP and the module you will just be making bad guesses and asking ambiguous questions.

    A "type' is read-only because it is not an item that can be changed.  It is an object that can be created, added and removed.


    • Edited by jrv Wednesday, April 24, 2019 10:35 PM
    Wednesday, April 24, 2019 10:34 PM
  • Anyway the answer is as follows:

    $ct = Get-PnpContentType $ctype
    $ct.ReadOnly = $false

    Does that look arbitrary?


    Wednesday, April 24, 2019 11:05 PM
  • If that solves your issue then you are set.  It was your question that was arbitrary.  The solution still doesn't make much sense and I suspect that it doesn't do what you want.


    Thursday, April 25, 2019 12:39 AM