2

Does anyone know of a Powershell script that can be used to pull user profile information from SharePoint Online 2013? The SharePoint server scripts are useless.

Particularly, we are looking for a script that will tell us if a user has a MySite/SkyDrive/OneDrive personal site

2 Answers 2

1

The following script allows you to access user profile properties for Sharepoint Online users.
Under PersonalSpace you can find either a link or an empty field. It will let you know if the user has the personal site.

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
$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)
    {
    Write-Host "User:" $User.LoginName -ForegroundColor Green
    $UserProfile.UserProfileProperties
    Write-Host ""
    }  
}

EDIT
Actually there is another way, much simpler, that doesn't involve scripting and still shows you which users have personal site.

Connect via SharePoint Management Shell and write in the console: Get-SPOUser -Site https://domain-my.sharepoint.com

You will get a list of list of users (+some extras) who created their personal site.

1
  • Is there a way to get this information using the REST API? Jan 4, 2016 at 12:13
0

I am working on a script that does this right now. Check out this example script, which uses the user profile service proxy to iterate through users. The script checks if($Url). If this value is true, the user has a provisioned OneDrive site.

1
  • Please post the relevant code directly in your answer, not by linking to an external site. Jan 11, 2018 at 19:51

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.