Block all personal sites (Sharepoint/OneDrive) - microsoft can't help directly

Occasional Contributor


Is there a way to lock all personal sites.

I found a script to block one site

Connect-SPOService -Url
$siteUrl = ""
$site = Get-SPOSite $siteUrl -Detailed
Set-SPOSite $site -LockState NoAccess

It works, but I have hundreds of sites to block. First I would need to list all sites and then one by one block them.

Is there a way to automate it and BLOCK all sites?

I want to lock sites temporarily. This lock prevent users that has a personal site to use them (new ppl are blocked by MySite setting).

I contacted Microsoft directly and they provided me with some data - they told me that I should use ForEach, but I have no idea how to use it, and they won't help me any further cause it is against some policy.

0 Replies