0

I am creating a Sharepoint List in Sharepoint Online. I am uploading from an excel file and I want all the columns to be read-only except for something like 'Status' or 'Notes.'

When I upload from Excel, the columns come in as editable, and the only way I know how to make them read only is to create a Calculated field using the editable field that was migrated from Excel, then hide the editable field.

This is a manual process and I have to do if for every column by clicking through Sharepoint List front-end.

Is there a way to have a script or something that will accomplish this for all the fields. I was looking at powershell scripts that might do this, but I do not have administrator privileges in powershell

1 Answer 1

0

Please run following PowerShell.

Note: The account to be used in the PowerShell should be the administrator of the site collection.

1.Create a csv file as following picture shows.

enter image description here

2.Please run below PowerShell.

 $Credentials=Get-Credential  
 $SiteURL = "https://tenant.sharepoint.com/sites/emilytest"
 $ListName = "list1"

 #Connect to PnP Online
 Connect-PnPOnline -Url $SiteURL -Interactive

 #Get the Context
 $Context = Get-PnPContext

 $filePath = “the local path of csv file, such as C:\columns.csv”  

 $csv = Import-Csv $filePath  
 $a = $csv.ColumnName

 ForEach($_ in $a) {  

      $_.ReadOnlyField = $True
      $_.Update() 
      $Context.ExecuteQuery() 

 }  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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