Add-PSSnapin Microsoft.SharePoint.Powershell
$url = "http://weburl"
$listName = "List Name"
$permissionLevel = "Permission Level Name"
$groupName = "Enter Group Name"
#Grant permission on all uniquely secured list items to the specified group
$web = Get-SPWeb $url; $list = $web.Lists[$listName]
$permission = $web.RoleDefinitions[$permissionLevel]
$principal = $web.SiteGroups[$groupName]
#Process each list item
foreach ($item in $list.Items) {
Write-Output ("Item #" + $item.ID.ToString())
#Check to see whether the item is uniquely secured
if ($item.HasUniqueRoleAssignments -eq $FALSE) {
Write-Output " No change, permissions are inherited."
}
else
{
#Find an existing role assignment for this principal
$assignments = $item.RoleAssignments
$assignment = $assignments | where {$_.Member.Name -eq $principal.Name}
if ($assignment -eq $NULL) {
#Add a new role assignment for the principal
$assignment = new-object Microsoft.SharePoint.SPRoleAssignment($principal)
$assignment.RoleDefinitionBindings.Add($permission)
$assignments.Add($assignment)
Write-Output (" Granted " + $permissionLevel + " to " + $groupName)
}
elseif ($assignment.RoleDefinitionBindings.Contains($permission) -ne $TRUE)
{
#Update the principal's role assignment to add the desired permission level
$assignment.RoleDefinitionBindings.Add($permission)
$assignment.Update()
Write-Output (" Updated " + $groupName + " permissions to " + $permissionLevel)
}
else
{
Write-Output " No change."
}
}
}
$web.Dispose()
Read Next
Migrate data from Source to Destination Library without changing the audit trail column values– PowerShell
Importing Best Bets as Query Rule in SharePoint 2013 using PowerShell
Tags
.NET
AI
ALB
API
ARM
ASPM
AWS
Actions
Amazon Bedrock
Angular
Ansible
Anti-Pattern
Architecture
Automation
Azure
Azure AD
Azure CLI
Azure Container Apps
BDC
Bash
Bitbucket
Bot
CDN
CI/CD
CLI for Microsoft 365
CSOM
Citrix
Claude AI
Cloud Computing
CloudFront
CloudWatch
Cloudflare Workers
CodeWhisperer
Community
Computer Vision API
Copilot
Data Extraction
DeepSeek
DefectDojo
DevOps
DevSecOps
Distributed Systems
Docker
Docker Scout
DynamoDB
EKS
ElastiCache
Event Driven
EventBridge
External Secrets Operator
Faith
Flask
GCP
Generative AI
GitHub
GitLab
GitLeaks
GitOps
Google Analytics
Governance
Graph API
Groups
HIBP API
Hashicorp
IAM
IaC
Identity
Incident-Response
InfoPath
Integration
Istio
JavaScript
Jenkins
Jinja2
Kafka
Kiali
Knowledge Base
Kubernetes
LLM
LUIS
Lambda
Lambda@Edge
LangChain
Linode
Linux
Lotus Notes
MCP
MCP server
Machine Learning
Manage Secrets
Media Processing
Microservices
Microsoft 365
Microsoft Power Platform
Migration
Milvus
Model Context Protocol
NJSScan
Nintex
OIDC
Office Store
Ollama
OpenAI
Performance Optimization
Permissions
Pinecone
PnP
Pod
Postman
Power Apps
Power Automate
PowerShell
Python
RAG
REST
Redis
Roles
S3
SNS
SPFx
SQL Server
SRE
SSL
SSRS
Security
Semantic Search
Semgrep
Serverless
Service Mesh
ServiceNow
SharePoint
Slack
Software Engineering
TFS
Teams
Terraform
VM
Vault
Vector Database
Vulnerability
Windows
Windows Server
YAML
Yammer
jQuery
tfsec