DEV Community

Tony Watters
Tony Watters

Posted on


How to make SharePoint column fields readOnly / Hidden with PnP PowerShell

    $tenantUrl = "",
    $spCredential = (Get-Credential),

$sites = @("siteOne", "SiteTwo")

foreach($name in $sites) {

    Connect-PnPOnline -Url $tenantUrl/sites/$name -Credentials $spCredential

    #Field Guids

    $Summary = Get-PnPField -Identity 98e1ecf3-3ae3-44a4-820c-f1de12ff346a
    $Country = Get-PnPField -Identity 7d9fd33a-e726-4d7f-b3ed-60e1c8e9690d
    $Location = Get-PnPField -Identity 0d2db348-a438-48f2-bcd2-461acd6f149f
    $Language = Get-PnPField -Identity 81b712c3-a41f-4e65-9a3a-8e7110bd9b5e
    $Topic = Get-PnPField -Identity 5f9fd169-0cf6-4779-a6be-e4635327c9a8

    $columns = $Summary, 

    foreach ($column in $columns) {

            $column.ReadOnlyField = $true
            Write-Host "error" $columns
    Write-Host "finished updating read Only fields in" $name

Enter fullscreen mode Exit fullscreen mode

Latest comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git