Liste todos os grupos disponíveis em uma organização, excluindo grupos dinâmicos de distribuição. Para recuperar grupos dinâmicos de distribuição, use o Centro de administração do Exchange.
Esta operação retorna, por padrão, apenas um subconjunto das propriedades de cada grupo. Essas propriedades padrão estão listadas na seção Propriedades. Para obter propriedades não retornadas por padrão, execute uma operação GET para o grupo e especifique as propriedades em uma opção de consulta $select do OData. As propriedades hasMembersWithLicenseErrors e isArchived são uma exceção e não são devolvidas na $select consulta.
Observação: Essa solicitação pode ter atrasos de replicação para grupos que foram criados, atualizados ou excluídos recentemente.
Escolha a permissão ou permissões marcadas como menos privilegiadas para esta API. Utilize uma permissão ou permissões com privilégios mais elevados apenas se a sua aplicação o exigir. Para obter detalhes sobre as permissões delegadas e de aplicação, veja Tipos de permissão. Para saber mais sobre estas permissões, veja a referência de permissões.
Este método suporta os $countparâmetros de consulta , $expand, $filter$orderby, $search, $select, e $topOData para ajudar a personalizar a resposta.
$skip não é compatível. Os tamanhos de página padrão e máximo são 100 e 999 objetos de grupo, respectivamente. Algumas consultas são suportadas somente quando se usa o cabeçalho ConsistencyLevel definido como eventual e $count. Para obter mais informações, veja Capacidades avançadas de consulta em objetos de diretório.
Para listar apenas grupos do Microsoft 365 (também conhecidos como grupos unificados), aplique um filtro em groupTypes:
GET https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c+eq+'Unified')
O $search parâmetro de consulta suporta a tokenização apenas nos campos displayName e description e requer o cabeçalho ConsistencyLevel. Campos que não displayName e descrição predefinidos para $filterstartswith comportamento.
As propriedades da extensão também suportam parâmetros de consulta da seguinte forma:
Não forneça um corpo de solicitação para esse método.
Resposta
Se bem-sucedido, este método retorna um código de resposta 200 OK e uma coleção de objetos group no corpo da resposta. A resposta inclui somente as propriedades padrão de cada grupo.
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync();
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.groups.get()
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade. Todas as propriedades padrão são retornadas para cada grupo em uma chamada real.
GET https://graph.microsoft.com/v1.0/groups?$filter=hasMembersWithLicenseErrors+eq+true&$select=id,displayName
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "hasMembersWithLicenseErrors eq true";
requestConfiguration.QueryParameters.Select = new string []{ "id","displayName" };
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphgroups "github.com/microsoftgraph/msgraph-sdk-go/groups"
//other-imports
)
requestFilter := "hasMembersWithLicenseErrors eq true"
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
Select: [] string {"id","displayName"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "hasMembersWithLicenseErrors eq true";
requestConfiguration.queryParameters.select = new String []{"id", "displayName"};
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "hasMembersWithLicenseErrors eq true",
select = ["id","displayName"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.groups.get(request_configuration = request_configuration)
GET https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName, 'a')&$count=true&$top=1&$orderby=displayName
ConsistencyLevel: eventual
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "startswith(displayName, 'a')";
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Top = 1;
requestConfiguration.QueryParameters.Orderby = new string []{ "displayName" };
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "startswith(displayName, 'a')";
requestConfiguration.queryParameters.count = true;
requestConfiguration.queryParameters.top = 1;
requestConfiguration.queryParameters.orderby = new String []{"displayName"};
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "startswith(displayName, 'a')",
count = True,
top = 1,
orderby = ["displayName"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.groups.get(request_configuration = request_configuration)
Exemplo 5: Utilize $search para obter grupos com nomes a apresentar que contenham as letras "Vídeo" ou uma descrição que contenha as letras "prod", incluindo uma contagem de objetos devolvidos
GET https://graph.microsoft.com/v1.0/groups?$search="displayName:Video" OR "description:prod"&$orderby=displayName&$count=true
ConsistencyLevel: eventual
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Search = "\"displayName:Video\" OR \"description:prod\"";
requestConfiguration.QueryParameters.Orderby = new string []{ "displayName" };
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.search = "\"displayName:Video\" OR \"description:prod\"";
requestConfiguration.queryParameters.orderby = new String []{"displayName"};
requestConfiguration.queryParameters.count = true;
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
search = "\"displayName:Video\" OR \"description:prod\"",
orderby = ["displayName"],
count = True,
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.groups.get(request_configuration = request_configuration)
O exemplo seguinte mostra um pedido que filtra por membershipRuleProcessingState para obter grupos dinâmicos. Você também pode filtrar pelas propriedades groupTypes (ou seja, $filter=groupTypes/any(s:s eq 'DynamicMembership')). Essa solicitação requer o cabeçalho ConsistencyLeveldefinido como eventual e a $count=true cadeia de caracteres de consulta pois a solicitação usa o not operador do $filter parâmetro de consulta. Para obter mais informações sobre a utilização de ConsistencyLevel e $count, veja Advanced query capabilities on directory objects (Capacidades de consulta avançadas em objetos de diretório).
Observação: os parâmetros de consulta $count e $search não estão disponíveis atualmente nos locatários do Azure Active Directory B2C.
GET https://graph.microsoft.com/v1.0/groups?$filter=mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'&$count=true&$select=id,membershipRule,membershipRuleProcessingState
ConsistencyLevel: eventual
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'";
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Select = new string []{ "id","membershipRule","membershipRuleProcessingState" };
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
mgc groups list --filter "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'" --count "true" --select "id,membershipRule,membershipRuleProcessingState" --consistency-level "eventual"
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'";
requestConfiguration.queryParameters.count = true;
requestConfiguration.queryParameters.select = new String []{"id", "membershipRule", "membershipRuleProcessingState"};
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "mailEnabled eq false and securityEnabled eq true and NOT(groupTypes/any(s:s eq 'Unified')) and membershipRuleProcessingState eq 'On'",
count = True,
select = ["id","membershipRule","membershipRuleProcessingState"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.groups.get(request_configuration = request_configuration)
GET https://graph.microsoft.com/v1.0/groups?$select=id,assignedLicenses&$filter=assignedLicenses/any()&$expand=members($select=id,displayName)
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","assignedLicenses" };
requestConfiguration.QueryParameters.Filter = "assignedLicenses/any()";
requestConfiguration.QueryParameters.Expand = new string []{ "members($select=id,displayName)" };
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphgroups "github.com/microsoftgraph/msgraph-sdk-go/groups"
//other-imports
)
requestFilter := "assignedLicenses/any()"
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Select: [] string {"id","assignedLicenses"},
Filter: &requestFilter,
Expand: [] string {"members($select=id,displayName)"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"id", "assignedLicenses"};
requestConfiguration.queryParameters.filter = "assignedLicenses/any()";
requestConfiguration.queryParameters.expand = new String []{"members($select=id,displayName)"};
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
select = ["id","assignedLicenses"],
filter = "assignedLicenses/any()",
expand = ["members($select=id,displayName)"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.groups.get(request_configuration = request_configuration)