Can any one help on how to set the SharePoint online site List/Library to read only using Power-Shell script?
2 Answers
There's no setting as such but you can give the List or Library unique permissions and set all groups/users to have only Read permissions to the list.
Here is an article that describes how to do this using PowerShell:
https://www.sharepointdiary.com/2017/09/make-sharepoint-list-library-read-only-using-powershell.html
You can use Set-PnPListPermission to remove and add users/groups permissions.
Two blogs for your reference:
SharePoint Online: Remove User or Group from List Permissions using PowerShell
SharePoint Online: Grant Permission to List or Library using PowerShell