0

I was wondering if there was an option to share and edit options using a script instead of going one by one.

So here's what I have to do:
I have folder ABC and inside there's folders 1, 2, 3, 4, and so on, each with the name of the user that is 1, 2, 3 and 4.

The folder ABC is shared to everyone, but my users can only see their own folder, eg.: User 1 can only see folder 1. The only exceptions being admin/owners of course.

It's just that I don't want to do it by hand for 200 people -.-
An automated script would help. Thanks ^^

0

Yes you can do that with PnP SPOnline.

Here is a good example how to do this https://collab365.community/using-powershell-pnp-create-permission-multiple-folders-office-365/

#1
$siteurl = "https://yourtenant.sharepoint.com/sites/sitename"                
#2
$listname = "Library/list name"          
#3
$access = "full control" 
#4
$Folders = Import-Csv "link to your CSV file"    


 #----------START OF SCRIPT DO NOT MODIFY----------#
 connect-PnPOnline –Url $siteurl –Credentials (Get-Credential)
 foreach ( $entry in $Folders )
 {

$foldername = $entry.name
$emailaddress = $entry.EmailAddress


#Create Folder
Add-PnPFolder -Name $foldername -Folder $listname 

#get folder properites from list
$listItem = Get-PnPListItem -List $listname -Query "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>$foldername</Value></Eq></Where></Query></View>"

Write-Host "setting folder up for $foldername"

#set permissions on the folder
Set-PnPListItemPermission -List $listname -Identity $listItem -User $emailaddress -AddRole $access -ClearExisting

}

 #----------END OF SCRIPT DO NOT MODIFY----------#
| improve this answer | |
  • I had to change the $access value because for some reason it only accepts the language that the page is in, which is not English. Besides that it works like a charm. Thanks ^^ – Ruaben Mar 8 '19 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.