End User PowerShell - Grant site permission to users with bulk CSV

Опубликовано: 19 Ноябрь 2024
на канале: SPJeff
242
0

Live coding demo to grant site permission to users with bulk CSV. Available to any end user and does not require SharePoint tenant admin, site collection admin, or high level access.

Cheers.

POWERSHELL SOURCE CODE

Connect to SPO using WebLogin
$siteUrl = "https://spjeffdev.sharepoint.com/site..."
Connect-PNPOnline -Url $siteUrl -UseWebLogin
Get-PnPWeb
Get-PnPList

Read CSV file
$csv = Import-Csv -Path "SPJeff-Grant-Site-Access.csv"

Loop each row in CSV and grant access to site
foreach ($row in $csv) {
$user = $row.User
$role = $row.Role
Write-Host "Granting $user $role access to $siteUrl"
Set-PnPWebPermission -User $user -AddRole $role
}