Powershell client context

Patil, Harish 1 Reputation point
2021-02-08T09:03:44.997+00:00

Hi Team,

I am using below code. I want to check is site collection is read only or not.

How to check site is read only through powershell client context.

Code:

$web = $clientContextSource.Web;
$clientContextSource.Load($web);
$clientContextSource.ExecuteQuery();

LogInfo "ClientContext initialized for Source, site title: $($web.Url)";

Thanks,
Harish Patil

Microsoft 365 and Office | SharePoint Server | Development

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. sadomovalex 3,561 Reputation points
    2021-02-08T15:46:34.27+00:00

    you need to load Site.ReadOnly property of appropriate site collection. You may do this by using helper PowerShell method Load-CSOMProperties of Garry Lapointe:

    Load-CSOMProperties -object $site -propertyNames @("ReadOnly")  
    

    Here is example of usage of this method: PowerShell script for listing master pages in all sites of Sharepoint Online site collection via CSOM.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.