In Teams. Lineuri to UserPrincipalName

Ramki 816 Reputation points
2022-05-23T12:06:05.047+00:00

Hi All

Scenario : i a bunch of Lineuri Numbers, in txt or CSV

i would like to get the Userprincipal Name, and Policy assinged to it.

can u help me

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,068 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yuki Sun-MSFT 40,856 Reputation points
    2022-05-24T06:17:20.057+00:00

    Hi @Ramki ,

    Scenario : i a bunch of Lineuri Numbers, in txt or CSV
    i would like to get the Userprincipal Name, and Policy assinged to it.

    Let's say the file includes the Lineuri numbers is formatted as follows and is located at "C:\test\1.csv":
    204900-1.png

    You can try copying the script below into Notepad, saved it as a .ps1 file and then run it from PowerShell. Then you would be able to get the UserPrincipalName and policies based on LineUri values and the result would be exported into a CSV file(c:\test\result.csv) :

    $LineURIs = Import-Csv C:\test\1.csv      
    $Data = @()      
    foreach($LineURI in $LineURIs){      
        $Data+=Get-CsOnlineUser | where{$_.LineURI -eq $LineURI.LineUri} | select LineUri,UserPrincipalName,*Policy*  
        }      
    $Data | Export-Csv c:\test\result.csv -NoTypeInformation  
    

    204944-2.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful