Enumere todos los grupos disponibles en una organización, excepto los grupos de distribución dinámicos. Para recuperar grupos de distribución dinámicos, use el Centro de administración de Exchange.
Esta operación devuelve de forma predeterminada solo un subconjunto de las propiedades de cada grupo. Estas propiedades predeterminadas se indican en la sección Propiedades. Para obtener propiedades que no se devuelven de forma predeterminada, realice una operación GET para el grupo y especifique las propiedades de una opción de consulta de OData $select. Las propiedades hasMembersWithLicenseErrors y isArchived son una excepción y no se devuelven en la consulta $select.
Nota: Esta solicitud puede tener retrasos de replicación para grupos que se crearon, actualizaron o eliminaron recientemente.
Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
Este método admite los $countparámetros de consulta , $expand, $filter, $orderby$search, $selecty $top OData para ayudar a personalizar la respuesta. No se admite $skip. Los tamaños de página predeterminados y máximos son 100 y 999 objetos de grupo, respectivamente. Algunas consultas solo se admiten cuando se usa el encabezado ConsistencyLevel establecido en eventual y $count. Para obtener más información, vea Funcionalidades avanzadas de consulta en objetos de directorio.
Para enumerar únicamente grupos de Microsoft 365 (también denominados grupos unificados), aplique un filtro en groupTypes:
GET https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/any(c:c+eq+'Unified')
El $searchparámetro de consulta admite la tokenización solo en los campos displayName y descripción y requiere el encabezado ConsistencyLevel. Los campos que no sean displayName y description se establecen de forma predeterminada en el $filterstartswith comportamiento.
Las propiedades de extensión también admiten parámetros de consulta como se indica a continuación:
No proporcione un cuerpo de solicitud para este método.
Respuesta
Si se ejecuta correctamente, este método devuelve un código de respuesta 200 OK y la colección de objetos group en el cuerpo de la respuesta. La respuesta incluye sólo las propiedades predeterminadas de cada grupo.
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.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://learn.microsoft.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://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.groups.get()
Nota: Se puede acortar el objeto de respuesta que se muestra aquí para mejorar la legibilidad. Se devolverán las propiedades predeterminadas para cada grupo de una llamada 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://learn.microsoft.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://learn.microsoft.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://learn.microsoft.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)
El siguiente es un ejemplo de respuesta que incluye solo las propiedades solicitadas.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups(id,displayName)",
"value":[
{
"id":"11111111-2222-3333-4444-555555555555",
"displayName":"Contoso Group 1"
},
{
"id":"22222222-3333-4444-5555-666666666666",
"displayName":"Contoso Group 2"
}
]
}
Ejemplo 3: Obtener solo un recuento de grupos
Solicitud
En el ejemplo siguiente se muestra la solicitud. Esta solicitud requiere el encabezado ConsistencyLevel establecido en eventual porque $count está en la solicitud. Para obtener más información sobre el uso de ConsistencyLevel y $count, vea Funcionalidades avanzadas de consulta en objetos de directorio.
Nota: Los parámetros de consulta $count y $search actualmente no están disponibles en inquilinos de Azure AD B2C.
GET https://graph.microsoft.com/v1.0/groups/$count
ConsistencyLevel: eventual
Respuesta
En el ejemplo siguiente se muestra la respuesta.
HTTP/1.1 200 OK
Content-type: text/plain
893
Ejemplo 4: Usar $filter y $top para obtener un grupo con un nombre para mostrar que comience por 'a', incluido un recuento de los objetos devueltos
Solicitud
En el ejemplo siguiente se muestra la solicitud. Esta solicitud requiere el encabezado ConsistencyLevel establecido en eventual y la cadena de consulta $count=true porque la solicitud tiene los parámetros de consulta $orderby y $filter. Para obtener más información sobre el uso de ConsistencyLevel y $count, vea Funcionalidades avanzadas de consulta en objetos de directorio.
Nota: Los parámetros de consulta $count y $search actualmente no están disponibles en inquilinos de Azure AD B2C.
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://learn.microsoft.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://learn.microsoft.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)
Ejemplo 5: Use $search para obtener grupos con nombres para mostrar que contengan las letras "Video" o una descripción que contenga las letras "prod", incluido un recuento de objetos devueltos.
Solicitud
En el ejemplo siguiente se muestra la solicitud. Esta solicitud requiere el encabezado ConsistencyLevel establecido en eventual porque $search está en la solicitud. Para obtener más información sobre el uso de ConsistencyLevel y $count, vea Funcionalidades avanzadas de consulta en objetos de directorio.
Nota: Los parámetros de consulta $count y $search actualmente no están disponibles en inquilinos de Azure AD B2C.
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://learn.microsoft.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://learn.microsoft.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)
En el ejemplo siguiente se muestra una solicitud que filtra por membershipRuleProcessingState para recuperar grupos dinámicos. También puede filtrar por las propiedades de groupTypes (es decir,$filter=groupTypes/any(s:s eq 'DynamicMembership')). Esta solicitud requiere el encabezado ConsistencyLevel establecido en eventual y la cadena de consulta $count=true porque la solicitud usa el operador not del parámetro de consulta $filter. Para obtener más información sobre el uso de ConsistencyLevel y $count, vea Funcionalidades avanzadas de consulta en objetos de directorio.
Nota: Los parámetros de consulta $count y $search actualmente no están disponibles en inquilinos de Azure AD 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://learn.microsoft.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://learn.microsoft.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://learn.microsoft.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://learn.microsoft.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://learn.microsoft.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)