If you need to programmatically add a user as a site owner to a OneDrive site (granting that person access to the other users OneDrive and all of their files) then use the following PowerShell script:
[csharp]$username = "someone@domain.com"<br> $password = Read-Host -Prompt "Please enter your password" -AsSecureString<br> $oldUser = Read-Host ‘What is the username of the person who has left the company? NOTE: replace any full stops "." with "_" ‘<br> $newUser = Read-Host ‘What is the username of the new owner?'<br> $newUserEmail = $newUser+’@emaildomain.co.uk'</p> <p>#update the tenant field and the e-mail domain in the URL below to match the same format the OneDrive URL currently follows:<br> $URL = ‘https://tenant-my.sharepoint.com/personal/’+$newUser +’_EMAILDOMAIN_co_uk'<br> $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)<br> #Change the tenant text below to point to your tenancy<br> Connect-SPOService -Url https://tenant-admin.sharepoint.com -Credential $cred<br> Set-SPOSite -Identity $URL -Owner $newUserEmail -NoWait</p> <p>[/csharp]