pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
989 stars 662 forks source link

[BUG] #2847

Open thiagobeier opened 4 years ago

thiagobeier commented 4 years ago

ERROR 01: Set-PnPFolderPermission not applying the permissions on a sharepoint online site with Portuguese (Brazil) language

ENG: Get-PnPFolder -Url 'Shared Documents/ROOT-Folder/SUB-folder01' | Set-PnPFolderPermission -List 'Documents' -User SEC_Group -AddRole edit

PT-BR: Get-PnPFolder -Url 'Documentos Compartilhados/ROOT-Folder/SUB-folder01' | Set-PnPFolderPermission -List 'Documents' -User SEC_Group -AddRole edit

log on https://portal.office.com go to sharepoint admin center create a new Team site language (English) = ok if language Portuguese (Brasil) = fails

ERROR 02 why do we need to run Set-PnPFolderPermission -List 'Documents' -User SEC_Group -AddRole edit where "-User" works for a security group and -Group doesn't?

STEPS - working in English to evaluate it find and replace Shared Documents by Documentos Compartilhados , where the team site was created in Portuguese (Brasil)

note #1: the sharepoint folder structure retrieved by get-pnp -url

Connect-PnPOnline -Url $SiteURL -UseWebLogin

$SiteURL = "https://mytenantname.sharepoint.com/sites/msft" $FolderName= "RootFolder" $RelativeURL= "/Shared Documents" #Relative URL of the Parent Folder

create the RootFolder

Try {

Connect to PnP Online

Connect-PnPOnline -Url $SiteURL -Credentials $Cred

sharepoint online create folder powershell

Add-PnPFolder -Name $FolderName -Folder $RelativeURL -ErrorAction Stop Write-host -f Green "New Folder '$FolderName' Added!" } catch { write-host "Error: $($_.Exception.Message)" -foregroundcolor Red }

create the subfolders structure

Config Variables

$SiteURL = "https://arbrenttributos.sharepoint.com/sites/msft" $FolderName= "subfolder01" $FolderName1= "subfolder02" $FolderName2= "subfolder03" $FolderName3= "subfolder04" $FolderName4= "subfolder05" $FolderName5= "subfolder06" $FolderName6= "subfolder07" $NewRootFolder = "RootFolder" $RelativeURL= "/Shared Documents/"+$NewRootFolder #Relative URL of the Parent Folder

Get Credentials to connect

$Cred = Get-Credential

Try {

Connect to PnP Online

Connect-PnPOnline -Url $SiteURL -Credentials $Cred

sharepoint online create folder powershell

Add-PnPFolder -Name $FolderName -Folder $RelativeURL -ErrorAction Stop Add-PnPFolder -Name $FolderName1 -Folder $RelativeURL -ErrorAction Stop Add-PnPFolder -Name $FolderName2 -Folder $RelativeURL -ErrorAction Stop Add-PnPFolder -Name $FolderName3 -Folder $RelativeURL -ErrorAction Stop Add-PnPFolder -Name $FolderName4 -Folder $RelativeURL -ErrorAction Stop Add-PnPFolder -Name $FolderName5 -Folder $RelativeURL -ErrorAction Stop Add-PnPFolder -Name $FolderName6 -Folder $RelativeURL -ErrorAction Stop Write-host -f Green "New Folder '$FolderName' Added!" Write-host -f Green "New Folder '$FolderName1' Added!" Write-host -f Green "New Folder '$FolderName2' Added!" Write-host -f Green "New Folder '$FolderName3' Added!" Write-host -f Green "New Folder '$FolderName4' Added!" Write-host -f Green "New Folder '$FolderName5' Added!" Write-host -f Green "New Folder '$FolderName6' Added!" } catch { write-host "Error: $($_.Exception.Message)" -foregroundcolor Red }

add security groups or users to subfolders

each security group members only edit their own folders

Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder01' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder01 -AddRole edit Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder02' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder02 -AddRole edit Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder03' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder03 -AddRole edit Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder04' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder04 -AddRole edit Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder05' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder05 -AddRole edit Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder06' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder06 -AddRole edit Get-PnPFolder -Url 'Shared Documents/RootFolder/subfolder07' | Set-PnPFolderPermission -List 'Documents' -User GG_subfolder07 -AddRole edit