SIGN UP MEMBER LOGIN:    
ARTICLE

How to Start Full Synchronization using powershell in SharePoint 2010

Posted by Vijai Anand Articles | Windows PowerShell January 05, 2011
In this article we will be seeing how to Start Full Synchronization to import the user profile in SharePoint 2010.
Reader Level:

In this article we will be seeing how to Start Full Synchronization to import the user profile in SharePoint 2010.

Once you have Configured Synchronization connections in the User Profile Service Application you need to run the "Start Full Synchronization" to import the user profiles. This can be done through UI, programmatically and using powershell commands. Here we will be starting the Full Synchronization using powershell.

PowerShell script:

#------- Get-SPServiceContext

function Get-SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApplication]$profileApp)
{
    if($profileApp -eq $null)
    {
        #----- Get first User Profile Service Application
        $profileApp = @(Get-SPServiceApplication | ? { $_.TypeName -eq "User Profile Service Application" })[0]
    } 
return [Microsoft.SharePoint.SPServiceContext]::GetContext(
        $profileApp.ServiceApplicationProxyGroup,
        [Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default)
}

$serviceContext= Get-SPServiceContext
$configManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)
if($configManager.IsSynchronizationRunning() -eq $false)
{
$configManager.StartSynchronization($true)
Write-Host "Started Synchronizing"
}
else
{
Write-Host "Already Synchronizing"
}

#--------- Alternate way
$siteUrl="http://serverName:4695/"
$site= New-Object  Microsoft.SharePoint.SPSite($siteUrl)
$serviceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site)
$configManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)
if($configManager.IsSynchronizationRunning() -eq $false)
{
$configManager.StartSynchronization($true)
Write-Host "Started Synchronizing"
}
else
{
Write-Host "Already Synchronizing"
}


Go the SharePoint Central Administration => Application Management => Manage Service Applications =>User Profile Service.

You could see the Profile Synchronization Status has been changed to Synchronizing.

power.gif

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Team Foundation Server Hosting
Become a Sponsor