tags:

views:

65

answers:

1

I have used the below code for fetching the user profile from sharepoint 2010.Error I am getting is object $cm is returning as null.

$site = Get-SPSite($PortalURL); $servercontext = [Microsoft.Office.Server.ServerContext]::GetContext($site); $site.Dispose();

Return the UserProfileConfigManager

$cm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigmanager($servercontext); $spm = Get-SPProfileManager $siteUrl

Please help me to resolve this.I have checked the user profile service and its up and ruuning.

A: 

I think you are disposing the connection before you should. Dispose at the end and you should be good

Mitchell Skurnik