In this blog, we are going to create a folder in Document Library and set unique permission to a user for this created folder using PnP Power Shell. The Administrator can set the required permission to a user depending on the organizational needs. Here we can use this script to set permission to a particular user. Please follow the below steps.
SharePoint-2013-Hosting1
Step 1
Run the ISE in administrative mode. Then declare variables named “sUrl”, “user”, “Folder Name”, and “SiteRelativeURL” to store the respective values.
Step 2
Connect to PnP online and get the credentials.
Connect-PnPOnline-Url$sUrl-Credentials (Get-Credential)
Step 3
To create the folder in the document, use the PnP commands as shown in the code.
Add-PnPFolder-Name$FolderName-Folder$SiteRelativeURL-ErrorActionStop
Step 4
Copy and run the below codes to create a folder in Document and to set unique permission in the folder for a user.
After running the script,
Folder “Team Project” is created successfully.
Now the permission is updated