Forum Discussion
Acidrs
Jul 01, 2020Copper Contributor
Wildcards using get-azureaduser
Hello, I am having a little trouble trying to query my azuread instance using powershell. I am running the follow command Get-AzureADUser -Filter "userPrincipalName eq '*@someemail....
clintoliveira
Oct 29, 2020Copper Contributor
Acidrs if you are managing a multi tenant environment and connect to each tenant using the tenant id eg.
Connect-AzureAD -Credential $credentials -TenantId $tenantid
then the best way to filter the userprincipalname bases on domains is by using the example stated in the previous comment:
Get-AzureADUser -All 1| where {$_.UserPrincipalName -like "*@domain.com"}
If you are managing one tenant with multiple domains then the fastest way to get objects with a specific domain is to use the MSOL module.
eg.
Get-MsolUser -All -DomainName domain.com
I have used this multiple times in the past without any issues.