Azure / Azure/azure-powershell

-First parameter for Get-AzAD* commands doesn't behave as expected

Open
#25,464 1 comment 0 reactions 1 assignee Claimed by @VeryEarly View on GitHub
Azure PS Team bug customer-reported Graph.Microsoft potential-pruning Tracking
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

`Get-AzAdUser -First 1` or `Get-AzAdGroup -First 1` should be implemented using the $top query parameter. In other words, the action should be on the server side. At the moment, things are happening on the client side--a bunch of Entra objects are part of the response, and then the first object is picked on the client side.

Also, `-First` parameter should have an alias parameter `-Top`.

### Issue script & Debug output

```PowerShell
PS> Get-AzAdUser -First 1 -Debug

DEBUG: ============================ HTTP REQUEST ============================
HTTP Method: GET
Absolute Uri:
https://graph.microsoft.com/v1.0/users

It should be:

DEBUG: ============================ HTTP REQUEST ============================
HTTP Method: GET
Absolute Uri:
https://graph.microsoft.com/v1.0/users?$top=1
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```

### Module versions

```PowerShell
PS> get-module az*

ModuleType Version PreRelease Name
---------- ------- ---------- ----
Script 2.19.0 Az.Accounts
Script 6.16.2 Az.Resources
```

### Error output

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.