[BUG] Get-PnPAzureADUser: -Select parameter ignored
Reporting an Issue or Missing Feature
The -Select parameter of the Get-PnPAzureADUser is being ignored.
Expected behavior
As per the Official Graph Documentation and the PnP Documentation, providing a value for the select query parameter should result in an alternative set of object properties being returned.
Actual behavior
The cmdlet returns the same default set of properties:

Steps to reproduce behavior
Looking at the associated traffic exchange with graph.microsoft.com reveals 2 underlying issues:
-
The names of properties specified in the value for the -Select parameter get appended to the default set, instead of being presented exclusively:

-
The returned payload does actually contain name-value pairs for the requested properties, but those seem to be ignored in the cmdlet output:

What is the version of the Cmdlet module you are running?
1.5.0
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [x] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
Bump
@sergeyz7 - I can indeed reproduce the issue. Meanwhile, you can use the Select-Object as a workaround while we look into it.

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
Is there an update to this issue? Using Select-Object is not a viable workaround, as this works only for properties that are returned by default by "Get-PnPAzureADUser"
It is not possible to retrieve other AAD User Properties like "Company", "City" or "Extensionattribute1" etc.
This should be resolved in the nightly build of PnP PowerShell that happens the night after this PR in PnP Framework gets merged: https://github.com/pnp/pnpframework/pull/460
Closing this issue for now assuming that resolves it. If it turns out it didn't, feel free to reopen this issue.
PR has been merged. You can test this with the latest prerelease of PnP PowerShell starting tomorrow, September 24, 2021.
It looks like this bug is not solved completely. In the commit that @KoenZomers realised, the properties that are passed with the -Select parameter are added to user.AdditionalProperties which only resolves problem 2 of the original issue. Problem 1 however isn't solved because all the default properties are still returned, even when the -select parameter is passed. The documentation states:
-Select Allows providing an array with the property names of specific properties to return. If not provided, the default properties will be returned.
Also example 5 of the documentation illustrates this behavior: "Retrieves only the DisplayName and extensionAttribute1 properties..."
However, I realize that correcting this behavior as documented is a breaking change. So perhaps the documentation of -Select needs to be modified to describe the current behavior (additional properties). To solve the issue, an extra parameter could be introduced to state that we don't want to receive all default properties, i.e. -IgnoreDefaultProperties.
For performance reasons, only the properties that are asked for should be retrieved from the Graph API.
Good idea @RobinDijkstra! I've added it as you suggested through https://github.com/pnp/powershell/pull/1575. You're welcome next time to add it yourself and file a PR, too :)