Get all public Sites - Poweshell

Jaime García 1 Reputation point
2022-04-01T17:46:42.103+00:00

Hi all!

I´m trying to get a list of all public and private team sites using SPO cmdlets.
Cant find a property that has this value.

I´ve tried PnP but is not working for me in my organization, I keep getting the error "This cmdlet does not work with a WebLogin/Cookie based connection towards SharePoint."

Thats why I´m trying to find a soluton using SPO.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CaseyYang-MSFT 10,341 Reputation points
    2022-04-04T07:42:25.13+00:00

    Hi @Jaime García ,

    You could use following PowerShell commands to export site collection information to .CSV file.

    Connect-SPOService -url "https://wendytest123-admin.sharepoint.com" -Credential (Get-credential)  
    Get-SPOSite -Detailed | Export-CSV -LiteralPath C:\Temp\SitesInventory.csv -NoTypeInformation  
    

    For Reference: SharePoint Online: Get All Site Collections using PowerShell
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Wendy Li_MSFT 1,711 Reputation points Microsoft Vendor
    2022-05-04T02:27:49.473+00:00

    @Jaime García Per my search, there is no property on the site self, but on the underlying Microsoft 365 Group. You can try to use Get-PnPMicrosoft365Group to check if you can get the public site.

    A similar blog for your reference:
    Get All the Public or Private Team Sites in SharePoint with PnP.PowerShell

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

    --------------

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments