powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Get-PnPAzureADUser: -Select parameter ignored

Open sergeyz7 opened this issue 5 years ago • 10 comments

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: Get-PnPAzureADUser_bug1

Steps to reproduce behavior

Looking at the associated traffic exchange with graph.microsoft.com reveals 2 underlying issues:

  1. The names of properties specified in the value for the -Select parameter get appended to the default set, instead of being presented exclusively: Get-PnPAzureADUser_bug2

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

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

sergeyz7 avatar May 04 '21 13:05 sergeyz7

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

github-actions[bot] avatar May 19 '21 02:05 github-actions[bot]

Bump

sergeyz7 avatar May 19 '21 09:05 sergeyz7

@sergeyz7 - I can indeed reproduce the issue. Meanwhile, you can use the Select-Object as a workaround while we look into it.

image

veronicageek avatar May 24 '21 20:05 veronicageek

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

github-actions[bot] avatar Jun 08 '21 03:06 github-actions[bot]

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

github-actions[bot] avatar Jun 23 '21 02:06 github-actions[bot]

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.

mbuergi avatar Aug 05 '21 10:08 mbuergi

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.

KoenZomers avatar Sep 17 '21 21:09 KoenZomers

PR has been merged. You can test this with the latest prerelease of PnP PowerShell starting tomorrow, September 24, 2021.

KoenZomers avatar Sep 23 '21 10:09 KoenZomers

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.

RobinDijkstra avatar Dec 28 '21 19:12 RobinDijkstra

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 :)

KoenZomers avatar Jan 28 '22 01:01 KoenZomers