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 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,601 Reputation points Microsoft External Staff
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.