Forum Discussion
Extract telephoneNumber/businessPhones in Graph via PowerShell
Hi all,
I am trying to extract the telephoneNumber from the businessPhones attribute in Entra via a PowerShell script. I call Get-MgUser, list the properties including businessPhones. No matter what I try I either get a System.String[] or a blank. I can extract all the extensionAttribute values using the dot operator, but no luck with telephoneNumber. After much searching and reading of the Learn documentation, I am rather stumped.
Any guidance will be appreciated.
Bruce
Some properties are considered "sensitive", so you might need additional permissions/admin roles to work with them. See for example this document: https://learn.microsoft.com/en-us/graph/api/resources/users?view=graph-rest-1.0#sensitive-actions
The other thing that comes to mind is to make sure to specifically request the property:
Get-MgUser -All -Property DisplayName,Id,businessPhones | select DisplayName,Id,businessPhones
2 Replies
- BBachtell6982Copper Contributor
VasilMichev,
When I did not export the results via the Export-Csv commandlet, all was good. The issue here was the curly braces around the businessPhone return value. I stripped the curly braces off, piped it to the Export-Csv commandlet, got the result I needed. I was way overcomplicating the issue.
Thank you. I have marked your answer as a solution because it did lead me down the correct path to a solution.
Bruce Some properties are considered "sensitive", so you might need additional permissions/admin roles to work with them. See for example this document: https://learn.microsoft.com/en-us/graph/api/resources/users?view=graph-rest-1.0#sensitive-actions
The other thing that comes to mind is to make sure to specifically request the property:
Get-MgUser -All -Property DisplayName,Id,businessPhones | select DisplayName,Id,businessPhones