Forum Discussion
SateeshKurella
Oct 08, 2024Copper Contributor
Read the site collection URLs in excel/CSV and replace the Email ID.in the "Allow access requests"
Hi All, I want to read Excel file which consist of Site collection URLs and replace the "Allow access requests" email ID. I have developed below script, #Config Variables $CSVPath = "C:\...
michalkornet
Oct 15, 2024Iron Contributor
Hi SateeshKurella, check the bolded lines, this time, the code should iterate through all the sites listed in the CSV.
$CSVPath = "C:\Temp\ListofURLs.csv"
#Get Data from CSV
$CSVData = Import-CSV -Path $CSVPath
foreach ($Row in $CSVData) {
$siteUrl = $row.SiteUrl
Connect-PnPOnline -Url $Row.SiteURL -Interactive
#Get the Web
$Web = Get-PnPWeb
#Enable Access Request for the site to a Email ID
$Web.RequestAccessEmail = "email address removed for privacy reasons"
$Web.SetUseAccessRequestDefaultAndUpdate($False)
$Web.Update()
$Web.Context.ExecuteQuery()
Disconnect-PnPOnline
}