Using Set-SPSite to lock specific sites in an Array

I have a list of a couple of thousand sites within our collection that are orphaned or have been inactive for a year or better. Some of them have Owners listed and some do not.

Reading through a few other forums and posts, it seems the Set-SPSite only works on the entire collection. Would it work on just the array of URLs? I need to lock access to the sites before we begin reviewing for records retention. I am thinking of the following.

#Set-SPSite -Identity https://<collection>.sharepoint.com -LockState NoAccess

Can I set the Identity to the $sites variable that is the uploaded CSV array?

$sites = import-csv "C:\<MyCSV>\Pilot-Remediation.csv"
#$Header = "URL"

Any help would be greatly appreciated.

I’m thinking you mean Set-SPOSite . See: Set-SPOSite (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

The Identity variable only takes a single site so you’d need to loop through them.

Assuming the CSV in your $sites variable has a column named URL that contains your sites,I it might look something like this:

$sites = Import-Csv 'C:\<MyCSV>\Pilot-Remediation.csv'

$sites | ForEach-Object {
    Set-SPOSite -Identity $_.url -LockState NoAccess
}


If you want to test against a single one you can access the first index of the $Sites variable like this:
$Sites[0]