Export SharePoint 2013 Site Collection Groups Name in Excel Using Powershell


This article explains how to export the SP2013 group names in Excel using a Powershell script.


  1. Ensure you have created a site collection and groups in a site collection.
  2. Ensure you have a Powershell window to execute the script.

Use the following procedure

  1. Add the following lines of code in a a text editor such as Notepad.
  2. Save the file as "GetAllGroups.ps1".

    #get the site object

    $site = Get-SPSite “ http:// yoursitecollection”

    #get the group collection details

    $groups = $site.RootWeb.sitegroups

    #output variable is been used for storing the group details.

    $Output = @("GroupName")

    #loop thru the groups object and get the individual group details.

    foreach ($grp in $groups)


    Write-Host "Group: " $grp.name;

    $Output += ($grp.name)



    #finally export the group names to the .csv file

    $Output > "C:\ ExportGroups.csv"

  3. In the code above snippet you are initialising a site object.
  4. Then in line 2, get the group collection details using the sitegroups property.
  5. Loop in the groups object to get the group name details in the site collection.
  6. Then finally dipose the site object and export the group names to the .csv file.
  7. Output variable has been used to store the group names.
  8. That's it!!Now let's start testing.


  1. Now to run the script, open the Powershell window by clicking on Run as administrator.
  2. Now navigate to the location where you have placed your Powershell script; in our case it's “GetAllGroups.ps1” at the location (cd “C:\GetAllGroups.ps1”).
  3. Click on the Enter button. Thats it.
  4. Now navigate to the “C:\” drive and you will be able to see the ExportGroups.csv file placed in ur “C:\” drive.
  5. If you open the document then you will be able to see the groups name in the CSV file.

    CSV file


Thus in this article you saw how to export the SP2013 group names in Excel/CSV using Powershell script.