Azure active directory 我可以使用Microsoft Graph API在MS团队中搜索我所属的所有团队/组中的文件吗

Azure active directory 我可以使用Microsoft Graph API在MS团队中搜索我所属的所有团队/组中的文件吗,azure-active-directory,microsoft-graph-api,microsoft-graph-teams,Azure Active Directory,Microsoft Graph Api,Microsoft Graph Teams,我一直在使用下面的API,其中我建议搜索团队ID/组ID “搜索值”) 我宁愿在我所属的所有组中搜索,而不使用组ID来搜索团队驱动器中的内容。任何线索将不胜感激

我一直在使用下面的API,其中我建议搜索团队ID/组ID

“搜索值”)


我宁愿在我所属的所有组中搜索,而不使用组ID来搜索团队驱动器中的内容。任何线索将不胜感激 我不相信有一个图形查询可以返回您可以访问的所有驱动器文件。您必须构建两个查询,一个用于查询您所属的组,然后在其中循环以对每个组执行搜索查询。要获取您是is/getMemberGroups成员的组的所有组ID


您可能可以使用powershell或一个简单的程序或任何可以调用graph的语言来实现

需要组id,请参阅。

您可以尝试Powershell获取所需的组,然后循环请求MS Graph API

#sign in your azure account
Connect-AzureAD

#get access token
function Get-AzureRMBearerToken
{
    [CmdletBinding()]
    Param
    (
        $TenantID,

        $AppID,

        $ClientSecret
    )

    $Result=Invoke-RestMethod -Uri https://login.microsoftonline.com/$TenantID/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://graph.microsoft.com/"; "client_id" = "$AppID"; "client_secret" = "$ClientSecret" }
    $Authorization = "{0} {1}" -f ($result.token_type , $result.access_token)
    $Authorization
}
$accessToken = Get-AzureRMBearerToken  -TenantID "{your tenant id}" -AppID "{application/client id}" -ClientSecret "{value in your client secret}"

#get all groups
$groups = Get-AzureADGroup -All

#request MS Graph API in the loop
Foreach($group in $groups){
    $url = "https://graph.microsoft.com/v1.0/groups/"+$group.ObjectId+"/drive/root/search(q='SEARCH_VALUE')"
    Invoke-RestMethod -Method Get -Uri $url -Headers @{ Authorization = $accessToken }
} 

注意:确保您的应用程序具有所需的权限。请参阅和。

我通过使用Graph API中当前提供的Beta版搜索驱动器项找到了解决方案。它从azure租户下您有权访问的所有团队驱动器和Sharepoint驱动器中详细搜索文件列表。

groupid是什么?对于团队,我尝试使用api获取所有组,但它返回空数组表示我没有任何组