admin管理员组

文章数量:1335861

I am using Microsoft GraphAPI to query a SharePoint list. The list has a field called Buyer. When I query a record for that buyer field, what is returned is a number associated with the user in the list permissions.

$ListitemConnection = Get-MgSiteListItem -SiteId $siteId -ListId $listId -ListItemId $ItemId -ExpandProperty "fields" -Property *
        $ListitemDetails = $ListitemConnection.Fields.AdditionalProperties
        $BuyerID = $ListitemDetails.BuyerLookupId

So in the above code $BuyerID will return a number such as "45". I would like to convert that number to the person's email address but am unsure how. I looked at the Get-MgUser command but that does not use the PropertyNameLookupID to find the user.

In case it matters, I am connecting to graph using an Azure appID/secret and our tenant.

Connect-MgGraph -ClientSecretCredential $ClientSecretCredential -TenantId $TenantID -NoWelcome

I would prefer to stick to a solution that only uses GraphAPI and does not require the use of PNP.PowerShell.

Can anyone offer a suggestion?

I am using Microsoft GraphAPI to query a SharePoint list. The list has a field called Buyer. When I query a record for that buyer field, what is returned is a number associated with the user in the list permissions.

$ListitemConnection = Get-MgSiteListItem -SiteId $siteId -ListId $listId -ListItemId $ItemId -ExpandProperty "fields" -Property *
        $ListitemDetails = $ListitemConnection.Fields.AdditionalProperties
        $BuyerID = $ListitemDetails.BuyerLookupId

So in the above code $BuyerID will return a number such as "45". I would like to convert that number to the person's email address but am unsure how. I looked at the Get-MgUser command but that does not use the PropertyNameLookupID to find the user.

In case it matters, I am connecting to graph using an Azure appID/secret and our tenant.

Connect-MgGraph -ClientSecretCredential $ClientSecretCredential -TenantId $TenantID -NoWelcome

I would prefer to stick to a solution that only uses GraphAPI and does not require the use of PNP.PowerShell.

Can anyone offer a suggestion?

Share Improve this question edited Nov 19, 2024 at 21:29 Mark D. MacLachlan asked Nov 19, 2024 at 21:21 Mark D. MacLachlanMark D. MacLachlan 113 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

After a lot of searching I finally found what I needed.

    $ItemID = $Listitem.Id
    $ListitemConnection = Get-MgSiteListItem -SiteId $siteId -ListId $listId -ListItemId $ItemId -ExpandProperty "fields" -Property *
    $ListitemDetails = $ListitemConnection.Fields.AdditionalProperties
    $BuyerID = $ListitemDetails.BuyerLookupId
    # Get the User Information List
    $UserList = Get-MgSiteList -SiteId $SiteID -Filter "DisplayName eq 'User Information List'" -Select Id
    # Get the user details using the LookupId
    $User = Get-MgSiteListItem -SiteId $SiteID -ListId $UserList.Id -ListItemId $BuyerID -Select "fields" -ExpandProperty "fields"
    # Extract the email address
    $BuyerEmail = $User.Fields.AdditionalProperties.UserName

本文标签: powershellReturn Email Address from SharePoint PeopleGroup using GraphAPIStack Overflow