Today, I got a requirement from my client. They want all users' profile data in a SharePoint custom list using PowerShell Command.
For Example - Display Name, Email id, Phone Number etc.
Using the below command, you can get all users' profile data in a SharePoint custom list.
Before this step, verify if your AD configuration service is activated or not. If it's not activated, please follow this link
https://sharepointumar.wordpress.com/2017/07/04/sync-user-profile-service-application-with-ad-map-sharepoint-properties-when-using-adi-active-directory-import/
After completing the AD sync Part.
- #Add SharePoint PowerShell SnapIn  
 - if not already added  
 - if ((Get - PSSnapin "Microsoft.SharePoint.PowerShell" - ErrorAction SilentlyContinue) - eq $null) {  
 -     Add - PSSnapin "Microsoft.SharePoint.PowerShell"  
 - }  
 - $site = new - object Microsoft.SharePoint.SPSite("http://sp1:1010/");  
 - $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);  
 - #Get UserProfileManager from the My Site Host Site context  
 - $ProfileManager = new - object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)  
 - $AllProfiles = $ProfileManager.GetEnumerator()  
 - # Open SharePoint List  
 - $SPServer = "http://sp1:1010/"  
 - $SPAppList = "Lists/PowerShellCMD/"  
 - $spWeb = Get - SPWeb $SPServer  
 - $spData = $spWeb.GetList($SPAppList)  
 - foreach($profile in $AllProfiles) {  
 -     #Create a new item  
 -     $newItem = $spData.Items.Add()  
 -     # Add properties to this list item  
 -     $DisplayName = $profile.DisplayName  
 -     $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value  
 -     $newItem["DispName"] = $DisplayName  
 -     $newItem["AccName"] = $AccountName  
 -     write - host "Profile for account ", $AccountName  
 -     $newItem.Update()  
 - }  
 
 If this is helpful for you, please share and follow me for more real word examples. Stay tuned!
Below is our output:
 
 ![SharePoint]()