Sharepoint 2010 List all imported profile users by PowerShell
27/04/2011 Leave a comment
#PowerShell Script - List All User Profiles - SharePoint 2010 #The scripts is distributet "as-is." Use it on your own risk. The author give no warranties, guarantees or conditions. #Add SharePoint PowerShell SnapIn if not already added if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } #Get ServiceContext from associated site $site = new-object Microsoft.SharePoint.SPSite("http://blog.bugrapostaci.com:8090"); $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() foreach($profile in $AllProfiles) { $DisplayName = $profile.DisplayName $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value #Do not delete setup (admin) account from user profiles. if($AccountName -ne "BLOG\Mossadmin") { write-host "Profile: ", $AccountName } } write-host "Finished." $site.Dispose()
note:this code is not belong to me thanks for that . I changed it a little .)