SOLVED

Powershell user phone number

%3CLINGO-SUB%20id%3D%22lingo-sub-1523793%22%20slang%3D%22en-US%22%3EPowershell%20user%20phone%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523793%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20guys%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20Powershell%20to%20connect%20to%20MicrosoftTeams.%3CBR%20%2F%3EI%20would%20like%20to%20retrieve%20the%20users%20phone%20number%2C%20like%20I%20can%20see%20when%20access%20%3CA%20href%3D%22https%3A%2F%2Fadmin.teams.microsoft.com%2Fusers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fadmin.teams.microsoft.com%2Fusers%3C%2FA%3E.%3CBR%20%2F%3EThe%20cmdlet%26nbsp%3BGet-TeamUser%20only%20shows%20UserId%2C%20User%2C%20Name%20and%20Role.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20option%2C%20any%20other%20command%2C%20or%20any%20other%20connection%20that%20shows%20the%20phone%20number%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help.%3C%2FP%3E%3CP%3EHernan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1523793%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPhone%20Number%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1526082%22%20slang%3D%22en-US%22%3ERe%3A%20Powershell%20user%20phone%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1526082%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F724919%22%20target%3D%22_blank%22%3E%40hernan-invosys%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHey%2C%3C%2FP%3E%3CP%3EYou%20can%20use%20the%20Skype%20for%20Business%20PowerShell%20module.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fid%3D39366%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fid%3D39366%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOnce%20installed%2C%20connect%20to%20the%20shell%20using%20%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EImport-Module%20SkypeOnlineConnector%0A%24sfboSession%20%3D%20New-CsOnlineSession%0AImport-PSSession%20%24sfboSession%20-AllowClobber%0AEnable-CsOnlineSessionForReconnection%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EI%20use%20the%20following%20command%20to%20get%20all%20the%20users%20with%20a%20telephone%20number%20assigned.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EGet-CsOnlineUser%20%7C%20Where-Object%20%20%7B%20%24_.LineURI%20-notlike%20%24null%20%7D%20%7C%20select%20UserPrincipalName%2C%20LineURI%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EHope%20this%20helps.%3C%2FP%3E%3CP%3ESteve.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1528620%22%20slang%3D%22en-US%22%3ERe%3A%20Powershell%20user%20phone%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1528620%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F522846%22%20target%3D%22_blank%22%3E%40S_Thomspon%3C%2FA%3E%2C%26nbsp%3Bmuch%20appreciated%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello guys, 

I'm using Powershell to connect to MicrosoftTeams.
I would like to retrieve the users phone number, like I can see when access https://admin.teams.microsoft.com/users.
The cmdlet Get-TeamUser only shows UserId, User, Name and Role. 

 

Is there any option, any other command, or any other connection that shows the phone number? 

 

Thanks for your help.

Hernan

2 Replies
Highlighted
Solution

@hernan-invosys 

 

Hey,

You can use the Skype for Business PowerShell module.

 

https://www.microsoft.com/en-us/download/details.aspx?id=39366

 

Once installed, connect to the shell using :

Import-Module SkypeOnlineConnector
$sfboSession = New-CsOnlineSession
Import-PSSession $sfboSession -AllowClobber
Enable-CsOnlineSessionForReconnection

I use the following command to get all the users with a telephone number assigned.

Get-CsOnlineUser | Where-Object  { $_.LineURI -notlike $null } | select UserPrincipalName, LineURI

Hope this helps.

Steve. 

Highlighted

Thanks @S_Thomspon, much appreciated