Hi @Roger Roger ,
Welcome to Q&A forum!
If you want to get how many users have access to User 1's OneDrive:
First, you need to add yourself as an administrator of User 1's OneDrive.
Non-official, just for reference.
Then, you can get the Sharing report in User 1's OneDrive.
Open User1's OneDrive, go to OneDrive settings--More Settings--Run sharing report, and you'll be asked where in the drive you want to save the report. The resulting csv file shows the different ways a file has been shared and with whom.
https://www.ytria.com/blog/onedrive-sharing-report-for-all-users/
Non-official, just for reference.
Finally, if you want to terminate sharing in batches, you can use PowerShell to remove the sharing link.
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://<tenant>-my.sharepoint.com/personal/<username>_<tenant>_onmicrosoft_com"
It breaks all the links shared, internal or external.
For more info., please see:
The PowerShell command you use to grant User 2 access to User 1's OneDrive is completely correct. The premise is that you have administrator privileges to User 1's OneDrive.
For your references:
Good day!
If the answer is helpful, please click "Accept as Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.