Hi @ネパリ サンデャ
We can try to get siteurl from $Row
. Please refer to the following script
#Config Variables
$CSVFile = "C:\Document.csv"
Try {
#Get the CSV file
$CSVData = Import-CSV $CSVFile
#Read CSV file and grant folder permissions
ForEach($Row in $CSVData)
{
$SiteURL=$Row.SiteURL
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
Try {
#Get the user
$Users = $Row.user
ForEach($User in $Users)
{
#Grant Permission to the Folder
Set-PnPList -Identity $Row.library -BreakRoleInheritance -CopyRoleAssignments
Set-PnPListPermission -Identity $Row.library -AddRole $Row.permission -User $User
}
}
Catch {
Write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
}
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.