We have 100+ site collections on csv file and we need to mark all sites into "Read Only" mode access based on csv file using powershell script. Anyone suggestion highly appreciate. we am trying below script but facing some issue. SharePoint 2013 environment
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$SitesColl = import-csv "C:\Users\xxxxxxx\test.csv"
foreach($Site in $SitesColl)
{
Set-SPSite -Identity "$site.Url" -LockState "ReadOnly"
}
Error :Set-SPSite : Cannot find an SPSite object with Id or Url:
@{Url=http://sharepoint.test.com/sites/xx}.Url.
At C:\Users\xxxxxxx\script.ps1:5 char:3
+ Set-SPSite -Identity "$site.Url" -LockState "ReadOnly"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share...SPCmdletSetSite:
SPCmdletSetSite) [Set-SPSite], SPCmdletPipeBindException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletSetSite