Take the 2-minute tour ×
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

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Portal")

$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 {$_.properties.objectcategory -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 = $person.properties
$prop.cn

$exists = $pmanager.UserExists($prop.cn)

if ($exists -eq $false)
{
$pmanager.CreateUserProfile($prop.cn)
}

$up = $pmanager.GetUserProfile($prop.cn)
$up.CreatePersonalSite()


}

http://blogs.architectingconnectedsystems.com/blogs/cjg/archive/2009/02/11/Powershell-script-to-create-Active-Directory-user-Profiles-and-MySites.aspx

EDIT

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     
    Try 
    { 
        if($profile.PersonalSite -eq $Null) 
        { 
            write-host "Creating personel site for  $AccountName"  
            $profile.CreatePersonalSite()        
            write-host "Personal Site Admin has assigned"  
        } 
        else 
        { 
            Write-Warning "$AccountName already has personel site" 
        } 
    } 
    Catch 
    { 
        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.

http://gallery.technet.microsoft.com/office/Pre-Provision-SharePoint-ec781ee9

share|improve this answer
2  
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 at 16:19

Your Answer

 
discard

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.