User Drive Mapping with One Drive for Business

The sample scripts provided here are not supported by Portal Architects. All scripts are provided AS IS without warranty of any kind. Portal Architects further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Portal Architects, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Portal Architects has been advised of the possibility of such damages.

 

Error with User-Drive Mapping and SharePoint

When creating a User Drive Mapping job with Office 365/SharePoint 2013/One Drive for Business as the destination, you may receive the following message: "This instance does not support OneDrive (or MySite) detection." 

This may be caused if One Drive for Business is not provisioned/installed, the source folder name cannot be mapped to a valid One Drive for Business library, or if the user has never accessed their One Drive and it has not been setup yet by the system.

Also note that due to how SkySync uses the connection identity to access each user’s One Drive / My Site, the connection identity must be granted access to user’s One Drive.  This can be accomplished via a PowerShell script.

When SkySync doesn’t have access to the user’s One Drive, you will see the error message “Response code does not indicate success: 404 (Forbidden)” in the job log.

Components Required:

To run the script, you will need the following components installed:

azure-cli.0.10.7 (Azure CLI)

AdministrationConfig_2 (Windows Azure Active Directory Module for Windows PowerShell Setup)

sharepointonlinemanagementshell_5806-1205_x64_en-us (SharePoint Online Management Shell)

msoidcli_64 (The Microsoft Online Services Sign-In Assistant)


The Script:

The following Powershell Script will prompt for the user to log in, retrieves all the admins and inserts them into a collection.

 Replace the  bold variable value examples below with your site-specific values.

$objCreds = Get-Credential
$siteAdminUrl = "https://skysyncdesktop-admin.sharepoint.com"
$sitePersonalBaseUrl = "https://skysyncdesktop-my.sharepoint.com/personal/"
$sitePersonalSuffix = "_skysyncdesktop_onmicrosoft_com"
 
Connect-SPOService -Url $siteAdminUrl  -credential $objCreds
Connect-MSOLService -credential $objCreds
$objRole = Get-MsolRole -RoleName "Company Administrator"
$colAdmins = Get-MsolRoleMember -RoleObjectId $objRole.ObjectId | Select EmailAddress
$colUsers = Get-MSOLUser -All | Select UserPrincipalName
Write-Host "Users"
 
foreach ($objUser in $colUsers){
     $strUser = $objUser.userprincipalname
     $intPos = $strUser.IndexOf("@")
     $strUser = $strUser.SubString(0, $intPos)
                 $strUser = $strUser.replace(".","_")
     $strSite = $sitePersonalBaseUrl + $strUser
     $strSite = $strSite + $sitePersonalSuffix
                 
     foreach ($objAdmin in $colAdmins){
                                  Write-Host $objAdmin.EmailAddress
                                  Write-Host $strSite
                                Set-SPOUser -Site $strSite -LoginName $objAdmin.EmailAddress -IsSiteCollectionAdmin $true
     }
}
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")