How to get the list of site Id by using get-mgsite? Is get-mgsite -serach"*" is this command still working?

Kavya Kasireddi 0 Reputation points
2023-09-06T08:53:47.2466667+00:00

Is there a possible way to get the list of sites. By using get-mgsite command.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
2,106 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
8,089 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,497 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,642 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
1,317 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 16,741 Reputation points Microsoft Vendor
    2023-09-07T07:02:12.29+00:00

    Hi @Kavya Kasireddi ,

    Welcome to Q&A forum!

    I am a SharePoint support engineer, and your question is also related to Microsoft Graph, which is not my field of expertise, so I add a related tag so that your question can be seen by Graph engineers. Regarding your question, I conducted research and testing and got the same results as you. The get-mgsite -serach "*" command did not return any results. But when I make an API call directly in graph-explorer, the expected result will be returned:

    09071

    So you can try to use graph-explorer or postman to make API calls.

    Or you can try using Get-SPOSite to get a list of all sites.

    You can refer to this blog:

    https://www.sharepointdiary.com/2016/02/get-all-site-collections-in-sharepoint-online-using-powershell.html

    Hope this helps.


    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.