Feb 14 2022 02:09 PM
Hi,
Looking for a way to place several hundreds of teams (mainly their SharePoint team sites) in read-only state after having migrated these from one tenant to another.
Been trying with the following script, but having no luck. Am I missing something? Or is it not possible to do this in a bulk operation?
$AdminCenterURL = "https://tenant-admin.sharepoint.com"
$sites = Get-SPOSite -Limit All -Filter { Url -notlike "*-my.sharepoint.com*" } # Get all sites excluding onedrive
Connect-SPOService -url $AdminCenterURL
Set-SPOSite $sites -LockState "ReadOnly"
Set-SPOSite : Cannot convert 'System.Object[]' to the type 'Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind' req
uired by parameter 'Identity'. Specified method is not supported.
At line:1 char:13
+ Set-SPOSite $sites -LockState "ReadOnly"
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-SPOSite], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Online.SharePoint.PowerShell.SetSite
Or is there another preferred approach? Thanks!
Feb 14 2022 05:53 PM
SolutionFeb 14 2022 05:53 PM
Solution