Tuesday, 23 August 2011

Crawl Component stuck at 'Recovering' status

Various blogs suggest to delete entirely the search service and start afresh. This a fairly drastic approach and not always practical with a production environment. Our fix was to create a new crawl component on the same server within Central Administration, this took 10 minutes to process but when it came back both the new and existing crawl components where online.


Crawl component stuck on ‘Recovering’








Two crawl components on same server.









Delete the new crawl component.


Wednesday, 10 August 2011

Export User Profile Data to CSV using PowerShell

I wanted to view all user profiles in SharePoint. However, SharePoint only allows to see 50 users. I wrote the following PowerShell script which exports all user profiles.

[Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
 
$siteurl = "http://mysite/"   
 
$site = New-Object Microsoft.SharePoint.SPSite($siteurl)
$context = [Microsoft.Office.Server.ServerContext]::GetContext($site)
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)


$upm.Count;
$profiles = $upm.GetEnumerator()
foreach ($userobject in $Profiles )
{
 $ln = $userobject.item("Lastname")
 $fn = $userobject.item("Firstname")
    $account = $userobject.item("AccountName")
 $user = $userobject.item("PreferredName")
 $office = $userobject.item("Office")
 Write-output "$fn;$ln;$user;$account;$office"
}
$site.Dispose()