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.