Answered by:
Lock the Sharepoint online site collection

Question
-
Hi,
I have to lock the SharePoint online site collection using power shell ,for that i got direct command but for that it requires the tenant administrator right ,I am having rights on site collection.How can I achieve that
Thanks.
RJ Thorat
Monday, November 7, 2016 8:41 AM
Answers
-
Hi,
If you don't have the tenant administrator permission, as a workaround, we can temporarily change all groups permission to Read Only.
Go to Site settings-> Site permission, then edit permission.
Best Regards,
Dennis
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com- Proposed as answer by Patrick_Liang Thursday, November 17, 2016 9:14 AM
- Marked as answer by Sjoukje ZaalMVP Friday, March 3, 2017 8:49 AM
Tuesday, November 8, 2016 2:30 AM
All replies
-
Hi
Seems using SharePoint Online PowerShell to lock the site collection needs SharePoint Online global administrator account.
Refer to:
https://social.msdn.microsoft.com/Forums/en-US/f71d377f-3ade-43f7-a49d-e08fba21c601/sharepoint-online-lock-site-collection?forum=sharepointadmin
Monday, November 7, 2016 9:14 AM -
You have to use Global SP admin account to unlock it using below power shell command:
$site = Get-SPOSite -Identity urlofsitecollection
Set-SPOSite -Identity $site -LockState UnLockMahi
Please Mark as answer if found useful :)
Monday, November 7, 2016 9:20 AM -
Hi,
You have two options to set the lock in SharePoint Online Site Collection :
PowerShell:
Set-SPOSite https://[tenant].sharepoint.com/sites/targetsite -LockState [NoAccess|Unlock]
CSOM:
using (var clientContext = new ClientContext(tenantUrl)) { clientContext.Credentials = spoCredentials; var tenant = new Tenant(clientContext); var siteProperties = tenant.GetSitePropertiesByUrl(siteUrl, true); clientContext.Load(siteProperties); clientContext.ExecuteQuery(); Console.WriteLine("LockState: {0}", siteProperties.LockState); siteProperties.LockState = "Unlock"; siteProperties.Update(); clientContext.ExecuteQuery(); }
However to use both you will have to be Tenant Admin, there is no other way.
More Info:
https://blogs.msdn.microsoft.com/sumanc/2014/11/19/how-to-change-the-lock-state-via-csom/
Thanks,
Priyan
Please Up Vote and Mark this as Answer if it helps.
Monday, November 7, 2016 10:11 AM -
Hi,
If you don't have the tenant administrator permission, as a workaround, we can temporarily change all groups permission to Read Only.
Go to Site settings-> Site permission, then edit permission.
Best Regards,
Dennis
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com- Proposed as answer by Patrick_Liang Thursday, November 17, 2016 9:14 AM
- Marked as answer by Sjoukje ZaalMVP Friday, March 3, 2017 8:49 AM
Tuesday, November 8, 2016 2:30 AM -
Hi
Here is a link to powershell script to Lock/ Unlock SharePoint Online sites in Office 365
https://gallery.technet.microsoft.com/office/LockUnlock-SharePoint-840efe54
Thanks
Rakhi
Tuesday, November 8, 2016 5:16 AM