Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have synced 5000 users from the AD, and I wish to create a MySite for all users without them having to access the site for it to be created. Is this possible?

share|improve this question

1 Answer 1

A powershell script that will create a profile for every AD user, then creates there My Site


$dom = "LDAP://CN=Users;DC=training;DC=corp"
$root = new-object DirectoryServices.DirectoryEntry $dom

$selector = new-object DirectoryServices.DirectorySearcher
$selector.SearchRoot = $root

$adobj = $selector.findall() | where {$ -match "CN=Person"}
$spsite = new-object Microsoft.SharePoint.SPSite("http://sharepoint2007:100")
$context = [Microsoft.Office.Server.ServerContext]::GetContext($spsite)
$pmanager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

ForEach ($person in $adobj)
$prop = $

$exists = $pmanager.UserExists($

if ($exists -eq $false)

$up = $pmanager.GetUserProfile($



this works for 2013 , i know its for 2010 but it works for 2013!

foreach($profile in $AllProfiles) 
    $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value     
        if($profile.PersonalSite -eq $Null) 
            write-host "Creating personel site for  $AccountName"  
            write-host "Personal Site Admin has assigned"  
            Write-Warning "$AccountName already has personel site" 
        Write-Error "Failed to create personal site for '$AccountName'" 

Each user's personal MySite will be automatically created when the user himself click the button "My Site"/"My Profile" first time, this will make user wait several seconds/minutes until the his MySite site creation is finished, it can save some time (or better experience) for users with using PowerShell to provision the users' MySites previously.

share|improve this answer
Since this post is from 2009 I guess it applies to SharePoint 2007 (or 2010). Did you try this out in 2013? – Engern May 28 '13 at 10:56
please check my edit out! its for 2010 but works and tested in 2013! the first script i know is for 2007/2010 but it also works for 2013 but needs ammending! – ali Sharepoint Dec 6 '13 at 11:08
As I do this but for users that are Office365 – user25817 May 13 '14 at 16:19
Does that work if users access directly SP MySite ? Without going on a SP Site first, and then Click on "One Drive" or "MySite" ? What if user directly goes on (which is the MySite collection) – Nico Jun 5 at 11:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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