Nov 23 2017 02:28 PM
Can anyone provide some information on the best practice on dealing with OneDrive documents that have been shared externally by users who have since departed the business? We are looking at a process to disable the sharing, but I can't find how to do this easily.
Thanks
Nov 23 2017 06:25 PM
Nov 23 2017 08:52 PM
We are looking to remove the sharing. Thanks for the idea, that seems a good one if there is nothing more formal.
Nov 23 2017 11:02 PM
Nov 25 2017 04:36 AM
Use the below PowerShell PnP script to remove the already created external shares for the OneDrive. To execute this script, the user should be OneDrive for Business Administrator and to do this follow this blog.
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() } } } } Remove-OneDriveSharingLink -OneDriveURL "https://tenantname-my.sharepoint.com/personal/alexw_tenantname_onmicrosoft_com"