Skip to main content
2 of 2
Including the most important tag, which I forgot to add

How to get All Users in User Profile Services Sharepoint 2013 Using CSOM

I need some function like bellow on CSOM. could you help me ?


if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { 
    Add-PSSnapin "Microsoft.SharePoint.PowerShell" 
} 

$site = new-object Microsoft.SharePoint.SPSite("<<WebApplicationSiteUrl>>");  
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);  

$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)    
$AllProfiles = $ProfileManager.GetEnumerator()  

foreach($profile in $AllProfiles)  
{  
    $DisplayName = $profile.DisplayName  
    $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value  
    write-host "Profile for account ", $AccountName
}  
write-host "Finished." 
$site.Dispose()