question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az ad user list --upn should support starts_with functionality like --display-name does

See original GitHub issue

I am not quite sure if its feature request or bug…

az ad user list --display-name "John Doe (Exter"

Will quckly find all users starting with "displayName" :"John Doe (Exter"

-> It will find John Doe (External) in this case, which is OK.

I suppose that:

az ad user list --upn "John.Doe@exa"

should do the same with "userPrincipalName" attribute

-> It will not find anyting, unless You supply full --upn name.

I understand that this is neccessary for az ad user show --upn-or-object-id to output only single result.

Is possible to use something like this:

az ad user list --query "[?starts_with(userPrincipalName,'John.Do')]"

but it takes almost 1,5 min in our environment, instead of almost instant output with az ad user list --upn "John.Doe@exa"

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
yugangw-msftcommented, Apr 26, 2019

You can use the --filter argument, e.g.

 az ad user list --filter "startswith(userPrincipalName, 'John.Doe')"

For full reference of the filter synatx, check out https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter

0reactions
jiaslicommented, Feb 1, 2021

@dshamanthreddy, your command looks good to me. Projecting displayName and mail requires MultiSelect Hash expression.

The command is working fine in my test:

> az ad user list --query "[].{name:displayName,mail:mail}" --output tsv
Admin06 admin06@xxx.onmicroosft.com
Admin07 admin07@xxx.onmicroosft.com

Things you may check:

  • Does the command return anything without --query and --output?
    az ad user list
    
  • Does CLI receive the correct argument? Make sure arguments are not parsed by the shell.
    > az ad user list --query "[].{name:displayName,mail:mail}" --output tsv --debug
    cli.knack.cli: Command arguments: ['ad', 'user', 'list', '--query', '[].{name:displayName,mail:mail}', '--output', 'tsv', '--debug']
    
Read more comments on GitHub >

github_iconTop Results From Across the Web

az ad user - Microsoft Learn
It is used to associate an on-premises Active Directory user account with their Azure AD user object. --mail-nickname. Mail alias. Defaults to user...
Read more >
How to perform Azure AD bulk operations with PowerShell
This tutorial will explain how to perform bulk operations with two PowerShell modules: the AzureAD module and the Azure Az module. What is...
Read more >
Get-AzureADUser -Filter Example - Easy365Manager
How to use the Get-AzureADUser cmdlet with filtering. PowerShell example code and some limitations and better options available.
Read more >
Get AzureADUser - How to Find Azure AD Users ... - LazyAdmin
Just like with the on-premise Active Directory can we manage our users in Azure AD with PowerShell. For this, we will need to...
Read more >
az ad user list -o table --filter "<options>(surname, 'brown')"
One of the workaround you can follow:- az ad user list -o table --filter "startsWith(surname, 'siewert')". The command you are trying to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found