1
votes

I have been using powershell to programmatically manage some tedious work in SharePoint Online (SPO) I have been using the Cmdlets of Powershell PnP. I have been looking for a cmdlet that will let me add/share give permission to a user so he/she can access this file located in a document library on SharePoint Online.

How can I share a SPO Document library file with edit or view permission using Powershell?

if you could please guide me in the right direction

Thank you

1

1 Answers

0
votes

There is a PnP cmdelt Set-PnPListItemPermission. You can use this to share the list item with your user.

Example use:

Set-PnPListItemPermission -List 'Documents' -Identity 1 -User '[email protected]' -AddRole 'Contribute'

This will provide the 'Contribute' permission to the user '[email protected]' for list item (document) with id 1 in the list 'Documents'

For more examples see the PnP Documentation for this cmdlet.