← script library
Automate User Permissions Management in SharePoint with PowerShell
SharePoint & OneDriveDecember 24, 2024
In this post, we will highlight a PowerShell script that facilitates the management of user permissions in SharePoint. Properly managing user access is essential for maintaining security and ensuring that the right users have access to the right resources. This script allows administrators to quickly add or remove user permissions for specific SharePoint lists or libraries, streamlining access control processes. Here is the PowerShell script for managing user permissions in SharePoint:
powershell
# Connect to SharePoint Online
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
$credential = Get-Credential
Connect-PnPOnline -Url $siteUrl -Credentials $credential
# Define user and permission details
$userEmail = "[email protected]"
$listName = "Documents"
$permissions = "Contribute" # Options: View, Edit, Full Control, etc.
# Add user permissions to the SharePoint list
Add-PnPListItemPermission -List $listName -User $userEmail -AddRole $permissions
Write-Host "Permissions for $userEmail have been updated in the list $listName with $permissions access."Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in SharePoint & OneDrive
Monitor SharePoint Site Usage with PowerShell
2025-01-04Streamline SharePoint File Permissions Management with PowerShell
2025-01-04Managing File Permissions in SharePoint with PowerShell
2025-01-04Efficiently List User Permissions in SharePoint with PowerShell
2024-12-24Efficiently Manage OneDrive File Permissions with PowerShell
2024-12-24Streamline File and Folder Permissions Management in SharePoint with PowerShell
2024-12-24Ready when you are.
Try ServerEngine free for 7 days.