Migrating from Get-AzureADUser to Get-MgUser
I am attempting to replicate a Get-AzureADUser command using Get-MgUser. The previous command (Get-AzureADUser -Top 5000 | Where-Object {($.AccountEnabled -eq “True”) -and (($.CompanyName -eq “CompA” -or $.CompanyName -eq “CompB” -or $.CompanyName -eq “CompC” -or $_.CompanyName -eq “CompD”))} | Select UserPrincipalName) selected the desired accounts. I have gotten this far with the replacement: Get-MgUser -All -Filter “AccountEnabled eq true” -Search “CompanyName:CompA” -ConsistencyLevel: eventual | Select UserPrincipalName
I have been unsuccessful in adding more search options for the CompanyName field. How do I use the -Search option to search for multiple values?
I noticed another discrepancy between the output of the two commands. Why does ‘Get-AzureADUser -ObjectID email address removed for privacy reasons’ display data for MailNickname but ‘Get-MgUser -UserID email address removed for privacy reasons’ shows the field as blank?
Since Microsoft is forcing us to rewrite all our scripts, it would be useful to have some assistance.
I am attempting to replicate a Get-AzureADUser command using Get-MgUser. The previous command (Get-AzureADUser -Top 5000 | Where-Object {($.AccountEnabled -eq “True”) -and (($.CompanyName -eq “CompA” -or $.CompanyName -eq “CompB” -or $.CompanyName -eq “CompC” -or $_.CompanyName -eq “CompD”))} | Select UserPrincipalName) selected the desired accounts. I have gotten this far with the replacement: Get-MgUser -All -Filter “AccountEnabled eq true” -Search “CompanyName:CompA” -ConsistencyLevel: eventual | Select UserPrincipalNameI have been unsuccessful in adding more search options for the CompanyName field. How do I use the -Search option to search for multiple values?I noticed another discrepancy between the output of the two commands. Why does ‘Get-AzureADUser -ObjectID email address removed for privacy reasons’ display data for MailNickname but ‘Get-MgUser -UserID email address removed for privacy reasons’ shows the field as blank?Since Microsoft is forcing us to rewrite all our scripts, it would be useful to have some assistance. Read More