1

I'm in sort of a sticky situation. I need to find a way to get a OneDrive personal URL for users that lack a SharePoint user profile. I don't know how they can have a OneDrive without a proper SharePoint profile, but they do.

I can't find a SharePoint REST API call that lets me get that information if the profile is missing. I also can't figure out whether or not it's safe to generate a URL based on a template, since some tenants have a custom URL, they won't have _onmicrosoft in their personal URL, right?

Any help would be greatly appreciated.

1 Answer 1

0

I don't recall where I had found this, but it was helpful to see who was using OD4B in our tenant using Powershell.

#Specify tenant admin and URL
$User = "[email protected]"

#Configure Site URL and User
$SiteURL = "https://yoursite-my.sharepoint.com"

#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)

#Bind to Site Collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Context.Credentials = $Creds

#Identify users in the Site Collection
$Users = $Context.Web.SiteUsers
$Context.Load($Users)
$Context.ExecuteQuery()

#Create People Manager object to retrieve profile data
$Output = "C:\Users\u531076\Desktop\Output.csv"
$Headings = "Name","Email","OneDrive URL","Phone","Job Title","Department"
$Headings -join "," | Out-File -Encoding default -FilePath $Output

$PeopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Context)
Foreach ($User in $Users)
    {
    $UserProfile = $PeopleManager.GetPropertiesFor($User.LoginName)
    $Context.Load($UserProfile)
    $Context.ExecuteQuery()
    If ($UserProfile.Email -ne $null)
        {
        $UPP = $UserProfile.UserProfileProperties
        Write-Host "Writing user data for " $UserProfile.DisplayName -ForegroundColor Green
        $Properties = $UserProfile.DisplayName.Replace(",", ""), $UserProfile.Email, $UserProfile.PersonalUrl, $UPP.WorkPhone, $UPP.'SPS-JobTitle'.Replace(",", ""), $UPP.Department
        $Properties -join "," | Out-File -Encoding default -Append -FilePath $Output
        }  
    }
}

It'll output a CSV and will provide you with the OD4B address or the generic link. I haven't ventured into trying to precreate OD4B spaces for users who have generic paths yet.

3
  • Well, that PowerShell script seems to rely on the PeopleManager, which only deals with users that have a SharePoint profile, so it doesn't really help... It looks like it might be useful in other situations though!
    – Ciddan
    Feb 16, 2015 at 18:27
  • @Eric Alexander How can I get this information through the REST API? Jan 4, 2016 at 12:24
  • @Ciddan Same question to you as well. Jan 4, 2016 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.