0

Function Remove-OneDriveSharingLink {

param (
$OneDriveURL )
process{

Connect-PnPOnline -Url $OneDriveURL 
$Ctx= Get-PnPContext


$Files= Get-PnPListItem -List "documents"
foreach( $File in $Files)
  {       
        $Froles= $File.RoleAssignments
        $Ctx.load($Froles)
        $Ctx.ExecuteQuery()

        If($Froles.Count -gt 0)
        {

          for ($i = $Froles.Count -1; $i -ge 0 ; --$i)  
           {   
              $Link=$Froles[$i].Member
              $Ctx.Load($Link)
              $Ctx.ExecuteQuery()
              If($Link.title -like "SharingLinks*")
              {
               $Froles[$i].DeleteObject()
              }
              $Link = $null
           }  
          $Ctx.ExecuteQuery()           
         }      
  }

} }

If i understand clearly this script, it removes all the sharinglink from all the files to everybody. I would like to know how to modify it in order to choose a person and a file and to remove the sharinglink from that file of that person. I would like to give the script a user and a file and the script remove the accees of this person to this file. If it is possible, how can i do it ? Thanks

Your Answer

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

Browse other questions tagged or ask your own question.