PowerShell Script to Export users List from SharePoint Group

  1. Add - PSSnapin "Microsoft.SharePoint.PowerShell"  
  2. $siteUrl = "http://SharePointSite.com/"  
  3. $groupName = "GroupName Users"  
  4. $Output = @ ("Login")  
  5. $web = Get - SPWeb $siteUrl  
  6. $site = $web.Site  
  7. $rootWeb = $site.RootWeb  
  8. $UserList = $rootWeb.Lists["User Information List"]  
  9. $web.SiteGroups[$groupName].Users | %  
  10. {  
  11.     $user = $UserList.GetItemById($_.ID)  
  12.     if ($user - ne $null)  
  13.     {  
  14.         $JobTitle = $user["JobTitle"]  
  15.         $Department = $user["Department"]  
  16.     }  
  17.     $Output += ($_.UserLogin)  
  18. }  
  19. $rootWeb.Dispose()  
  20. $web.Dispose()  
  21. $site.Dispose()  
  22. $Output > "C:\MembersExport.csv"