Change files and folder permissions on OneDrive for Business with Powershell

A couple of weeks ago, a customer, asked me about the possibility to create a Service Request with System Center Service Manager that, in early stages, can dynamically and automatically create documents to share, to be completed and finally be signed digitally by different people in different areas. It wasn't a big challenge until I try to change permissions to files on OneDrive to grant access only for Reviewers for that activity, and remove permissions for everyone not directly involved in the review activity.

 

img1

 

So I create this powershell script able to invoke the OneDrive for Business API and change permissions: it works like a charms :)

1) Download the SharePoint Online Management Shell from here and install it

2) Download the connectTo-Onedrive script

3) Open it and modify the variables with your data

 

img22

(yes, I've to improve the password area in order to hide data... if you have suggestions about it, write me a comment, I'll be glad to update the script

4) Execute the script manually... and then integrate it with Orchestrator or SMA!

 

img4

 

img3

Enjoy and as usual, if you have any comment or suggestion, feel free to ask me in comments

have a good lazy day! :)