Get status of SharePoint online site

sns 9,246 Reputation points
2021-12-15T06:00:19.263+00:00

How do we get the status of SharePoint online site like on premises ( locked , not locked, adding content prevented , active status )
How do we set site to lock or unlock in SharePoint online ?

Please help

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. JoyZ 18,111 Reputation points
    2021-12-15T07:52:46.317+00:00

    @sns ,

    We can use following pnp powershell to get and set -LockState property of current site:

    #Parameter  
    $SiteURL = "https://tenant.sharepoint.com/sites/Team1"  
    $UserName="******@tenant.onmicrosoft.com"  
    $Password= "xxxxxxx"  
      
    $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force  
    $Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword  
      
    #Connect to PnP Online  
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred  
      
    Set-PnPSite -LockState "ReadOnly"  
    Get-PnPTenantSite -Filter "LockState -eq 'ReadOnly'"   
    

    Unlock to unlock the site and make it available to users.

    ReadOnly to prevent users from adding, updating, or deleting content. A message will appear on the site stating that the site is under maintenance and is read-only.

    NoAccess to prevent users from accessing the site and its content. If you've provided a NoAccessRedirectUrl value for your organization (below), traffic will be redirected to the URL you specified. If you haven't set this URL, a 403 error will be displayed.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful

Your answer

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