title: Sharepoint permissions to folders using powershell pnp
body: <pre><code>$credentail = Import-Clixml D:\cred.xml
  $siteurl = "https://metho.sharepoint.com/sites/EducationandHumanities41"
  $access = "Read"
  $folders = Import-csv "C:\Users\metho\Desktop\sharepoint_Permissions.csv"
  
  Connect-PnPOnline -Url $siteurl -Credentials $credentail 
  
  
  
  
  Foreach ($entry in $folders) {
  $ListName = $entry.'Assoc Dean Area Name'
  $foldername = $entry.'Curriculum Area Name'
  $foldername2 = $entry.'Course Title'
  $foldername3 = $entry.c16
  $Nameofthefolder = $entry.currTeamName
  $emailAddress= $entry.facultyHeademail
  $UserOne = $entry.DeanName
  
  
  #Get-PnPFolder -Url $Listname
  
  $ListitemID = Get-PnPListItem -List $ListName
  
  
  #$listItem = Get-PnPListItem -List $Listname -Query "&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='Id'/&gt;&lt;Value Type='Text'&gt;$ListName&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;"
  
  
  Set-PnPListItemPermission -List $Listname -Identity $ListitemID -User $UserOne -AddRole $access 
  
  
  }
  </code></pre>
  
  <p>I am struggling to Apply the permissions to all the sub-folders under a SharePoint "Document Library". I am struggling (Which i think is the Issue) with the IDs of sub-folders. If i add the ID manually then it would apply the permissions to that particular ID of folder but i am looking to apply to all the sub-folders under a Document Library.</p>
  
  <pre><code>Set-PnPListItemPermission : Cannot convert 'System.Object[]' to the type 'SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind' required by parameter 'Identity'. Specified method is not supported.
  At line:31 char:53
  + ... t-PnPListItemPermission -List $Listname -Identity $ListitemID -User $ ...
  +                                                       ~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (:) [Set-PnPListItemPermission], ParameterBindingException
      + FullyQualifiedErrorId : CannotConvertArgument,SharePointPnP.PowerShell.Commands.Lists.SetListItemPermission
  </code></pre>