Showing posts with label User profile. Show all posts
Showing posts with label User profile. Show all posts

Thursday, November 10, 2011

Manual creation of a MySite Site Collection

It just happens that sometimes we need to do something out of the normal process. In this case, I had to manually create a MySite site collection for a user.

Manual creation using UI doesn't give any error message but it doesn't work. Site was created & the structure in place but when I click My Contents (content if for a different user), nothing happens.

So I tried using PowerShell. Below is the code that I used, which was adapted from another blog post.

$mysiteHostUrl = "<your MySite Host URL>"
$mysite = Get-SPSite $mysiteHostUrl
$context = [Microsoft.Office.Server.ServerContext]::GetContext($mysite)
$upm =  New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$AllProfiles = $upm.GetEnumerator()
foreach($profile in $AllProfiles)
{
   if ($profile.DisplayName -like "User Name")
   {    
      if($profile.PersonalSite -eq $Null)
      {
           write-host "Creating personal site for ", $profile.DisplayName
           $profile.CreatePersonalSite()
           write-host "Personal site created"
      }
      else
      {
           write-host $profile.DisplayName ," has already personal site"
      }
   }
}
$mysite.Dispose();

A Few important notes:

1. Initially, when I test this in my dev environment, the line below returned null all the time even though the personal site exist.

$profile.PersonalSite

I guess something is wrong with the User Profile Service (UPS). When I tried the code in another environment, it returned the expected values. So we need to verify first if the our UPS is working fine before attempting to run the code.

2. If line below gives you an error,

$upm =  New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

give the account you are running the powershell full control in 2 places - see below



Code above was adapted from: http://blog.bugrapostaci.com/2011/10/03/create-all-users-personal-site-via-powershell-script-sharepoint-2010/

Friday, April 1, 2011

No users in SharePoint 2010 after successfull profile import

Well, to start with, to say it is successful is misleading but that is the scenario we faced.

In our brand new SharePoint 2010 farm, we configured profile synch from AD. Everything looks cool but no users was found. Not sure where they are going but the data is simply not in the user profile store. Luckily google and technet forum helped :-).  No error messages and no clue until I came across a technet post which I believe was written for SharePoint 2007 but I gave it a try.

But first, try to search for the users. SharePoint 2010 does not list the users. You need to search for them. Just type any letter and search. If no values returned, then you can try the below steps.

This what I did

1. From the Admin Tools --> Servicess Stopped the SharePoint Timer service

2. From the Central Admin --> Services on Server, stopped both the User Profile Service and User Profile Synchronization Service

3. Navigated to the C:\ProgramData\Microsoft\SharePoint\Config\<GUID> folder

4. Removed all the other xml files

5. Edited the cache.ini file to replace the value with 1 and saved the file

6. Started back the SharePoint Timer service, waited till all the xml files were recreated and the number on cache.ini file return to its original value

7. Started back the User Profile Service and User Profile Synchronization Service

8. Then under CA --> Application Management --> Manage Service Application --> User Profile --> Start Profile Synchronization

9. Waited and it worked :-)

10. The users will not be listed. You need to search for them.

Ref:  Technet forum post