We have a requirement to set SP online sites to read-only post migration to another tenant. We have Site collection admin rights and we need to do this for 100 sites a week. We need to avoid the manual effort of creating site policies. So far the 2 automated options for us are -
Connect-SPOService "https://$tenant-admin.sharepoint.com"
Set-SPOSite $siteUrl -LockState "ReadOnly"
However, we wont be provided the tenant admin rights so cant use the connect-sposervice command.
- Activate the site policy feature at the site collection level, create a site policy manually in each site collection and then activate the policy using the script below.
$SitePolicyToActivate = Get-PnPSitePolicy -Name $PolicyName | Select-Object -Property Name
However, we would need to avoid the manual effort of creating the site policy. We checked that the content type hub is not enabled for the tenant and we cant publish the policy across any site collections.
Is there a feasible automated way to achieve activating the site policy using script with only Site collection admin rights? Any help in this regard is appreciated.