Reputation: 535
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
Upvotes: 1
Views: 1426
Reputation: 20788
createdByUser
is a relationship defined for baseItem
, so you need to use expand.
Get-MgSite -SiteId $siteId -Property "id,displayName,name,webUrl,createdDateTime,createdBy" -ExpandProperty "createdByUser"
But the response from GET /v1.0/sites/{site-id}
endpoint is quite unexpected
GET /v1.0/sites/{site-id}
returns properties: createdDateTime,description,id,lastModifiedDateTime,name, webUrl,displayName,root,siteCollection
.
According to the documentation createdBy,lastModifiedBy,lastModifiedDateTime
defined on baseItem are missing in the response.
GET /v1.0/sites/{site-id}?$select=id,displayName,name,webUrl,createdDateTime,createdBy&$expand=createdByUser
returns only createdDateTime,name,webUrl,displayName
.
id,createdBy,createdByUser
are missing.
It seems to me that there is a bug on the server side.
Upvotes: 0
Reputation: 738
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
Upvotes: 0