Monday 18 July 2011

Sharepoint 2010 : Create a mysite for each SharePoint profile (Powershell)

So we have spent an amount of time (hopefully not too much ha) configuring the User profile service and the synchronisation which imports profiles from AD. Our filters are in place so we only have valid profiles.

For the next step we would like to automatically create all the mysites in one hit.

This may or may not be a good idea depending on your exact business requirements but if it is what you want here is a script which will iterate through the profiles and create you a my site for each user.

$site = new-object Microsoft.SharePoint.SPSite("http://mysitehost"); 
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site); 


$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext); 
$AllProfiles = $ProfileManager.GetEnumerator();


foreach($profile in $AllProfiles) 
  
     $profile.CreatePersonalSite();
}


Great fun don't you reckon.

2 comments:

  1. Is there a way to get my sites created, for just one AD group?
    Thanks

    ReplyDelete
  2. This is good to know. BTW, how do we create mysite for new users instead of running this script manually every time?

    ReplyDelete