Sharepoint Online Powershell command to get list of users exported without cutting off the groups RRS feed

  • Question

  • I need to get an export of all the users in a site collection and export it to a csv in column format.  I can get it to export to a text file but it cuts off the groups with "...}".  I've tried several variations of the script below but nothing is getting me what I need.  

    Get-SPOUser -Site "My site" -Limit All | Tee-Object c:\filename.txt

    Any help would be appreciated. 

    S Boyd

    Friday, March 31, 2017 7:53 PM

All replies

  • Try this:

    Get-SPOUser -Site https://tenant.sharepoint.com/ -Limit All | select DisplayName,LoginName,IsSiteAdmin,IsGroup,@{n="Groups";e={$_.Groups -join ";"}}  | Export-Csv -nti "blabla.csv"

    • Proposed as answer by Patrick_Liang Monday, April 10, 2017 10:05 AM
    Saturday, April 1, 2017 7:59 PM
  • This is working but I need to filter to only get users who are in groups where the group title has the word "Power" in it.  Is this possible?

    S Boyd

    Monday, April 3, 2017 1:57 PM
  • You can filter the CSV file in Excel?
    Monday, April 3, 2017 10:58 PM
  • Hi S Boyd,

    Try using the following commands with Get-SPOSiteGroup method to get users in the specific groups in SharePoint Online site.

    $siteURL = "https://<tenant>.sharepoint.com/sites/<site>"
    $x = Get-SPOSiteGroup -Site $siteURL
    foreach ($y in $x)
    	if($y.Title -like "*Power*"){
    		Write-Host $y.Title -ForegroundColor "Yellow"
            	Get-SPOSiteGroup -Site $siteURL -Group $y.Title | Select-Object -ExpandProperty Users

    Information about how to get SharePoint Online Site groups with PowerShell:


    Here is a demo about how to get groups with users in SharePoint Online and output CSV file:


    Best Regards,

    Linda Zhang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Proposed as answer by Patrick_Liang Monday, April 10, 2017 10:05 AM
    Thursday, April 6, 2017 3:13 AM
  • The script is pulling all the "Power" user groups but I can't get it to export to the CSV file.  The link you included for an example (second one) didn't provide any examples of how to get it to the csv file.  Patrick's script exports to csv in the correct format but it gets all the groups.  I can filter and get just the power users but I would like to adjust the script to only pull the "Power" groups. I could use the script and adjust it for other purposes if I can get it to work. 

    S Boyd

    Thursday, April 13, 2017 2:43 PM
  • What Vasil provided was brilliant.  Incredibly simple.  No loops, just piping.  Thank you.  Works exactly as shown in his first reply - just update the URL and Export-csv path.  

    Wednesday, October 31, 2018 6:50 PM
  • Thank you, Michev!
    Tuesday, February 11, 2020 8:00 PM