Jump to content

Recommended Posts

Posted

Morning,

 

I need to create a custom permission on a library to upload the files to certain users.

 

I want to restrict them to open other files within that library. They can view the files and folders structure but can’t open.

 

Thanks

Posted (edited)

Take a look at the Student Work document library in a Site that is part of a class Team (where at least one assignment has been set).

 

We abuse this a lot.

 

 

Prior to that we had PNP scripts that manipulated permissions. [edit found a template -- below. It uses the depreciated AAD stuff so probably needs at least a gentle reworking for graph. Not sure about PNP these days either, or whether it would work with pwsh7]

 

$SiteName = "SITENAME"

$Group = "AADSECURITYGROUPNAME"

$SiteAbsoluteURL = "https://TENANTNAME.sharepoint.com/sites/" + $SiteName

$SiteRelativeURL = "/sites/" + $SiteName

$listname = "DOCUMENTLIBRARYNAME"

$listnameAsRelativeURL = "/" + $listname

$FolderServerRelativeURL = $SiteRelativeURL + $listnameAsRelativeURL

 

connect-azuread

Connect-SPOService https://TENANTNAME-admin.sharepoint.com

Connect-PnPOnline -Url $SiteAbsoluteURL -UseWebLogin

 

 

 

new-pnplist -Title $listname -Template DocumentLibrary -OnQuickLaunch

 

$UserList = (Get-AzureADGroup -SearchString $group|Get-AzureADGroupMember)

foreach ($user in $UserList)

{

#write-host $user.givenname $user.surname

$userFolderName = $user.givenname + " " + $user.surname

$targetFolder = $FolderServerRelativeURL + "/" + $userFolderName

Write-Host $userFolderName

Write-Host $user.UserPrincipalName

Add-PnPFolder -name $userFolderName -Folder $listnameAsRelativeURL

#write-host "Set-PnPFolderPermission -List"+ $listname +"-Identity " + $targetFolder +"-AddRole edit -User " + $user.UserPrincipalName "-ClearExisting"

Set-PnPFolderPermission -List $listname -Identity $targetFolder -AddRole edit -User $user.UserPrincipalName -ClearExisting

Set-PnPFolderPermission -List $listname -Identity $targetFolder -AddRole edit -User "SOMEOTERUSERWHOYOUWANTTOACCESSEVERYTHING"

Edited by psydii

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...