powershellmicrosoft-graph-apimicrosoft-graph-sdksmicrosoft-graph-sites

Cannot Get Get-MgSite to return CreatedBy or CreatedByUser


I'm using the Microsoft Graph PowerShell SDK to try and get some data from SharePoint sites using the Get-MgSite command. I'm running this command specifically

$site = Get-MgSite -SiteId <siteId> -Property Id,DisplayName,Name,WebUrl,CreatedDateTime,CreatedBy,CreatedByUser

I also tried this command

$site = Get-MgSite -SiteId <siteId> -Property Id,DisplayName,Name,WebUrl,CreatedDateTime,CreatedBy -ExpandProperty CreatedByUser

The $site variable contains all the requested items from the Property parameter except for the CreatedBy and CreatedByUser. I see in the documentation that the CreatedBy and CreatedByUser on the site resource are actually inherited from the baseItem type.

Is it possible to get the CreatedBy or CreatedByUser properties through the Get-MgSite command or is this data not returned through that endpoint?

I know it's not the same thing, but the SharePoint Admin Center does show a value for Created by when you view site properties

enter image description here


Solution

  • As per the documentation , there is no Createdby.CreatedByUser property avaialable ,you can check "createdDateTime" property which is inherited from baseItem , please see the list of property available - https://learn.microsoft.com/en-us/graph/api/resources/site?view=graph-rest-1.0#properties

    Hope this helps

    Thanks