Forum Discussion
Lineuri to UPN - Help Urgent
Hello Team
Looking for some urgent to help
i have list of around 1000+ LINEURI numbers and i using the below small script to get the output of who is using these numbers from Teams powehell.
Please help
===========================
$numberList = import-csv "D:\Inputs\numbertoupn.csv"
Foreach ($Num in $numberist) {
Get-CsOnlineUser -Filter {lineuri -eq '"$USer.num"'} | Select-object userprincipalname, Enterp*, Lineuri, AccountEnabled | Export-Csv D:\output\results.csv -append
}
ERROR
=================================================================
Correlation id for this request : a5fc2248-0edc-4fa0-be8c-51c69118358e
Get-CsOnlineUser : Phone number has non digit chars. "$USer.num"
At line:2 char:1
+ Get-CsOnlineUser -Filter {lineuri -like '"$USer.Name"'} | Select-obje ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ PageSize = , ...eleteduser = }:<>f__AnonymousType92`12) [Get-CsOnlineUser], Excep
tion
==================================================================
Hello Ramki
You could do a Write-Host $USer.num to see what numbers you are trying to match on the -eq query. There is probably something going wrong there. It looks like your format might be off or it might be recognized as an object instead of a number.
You can do what you are trying to achieve as follows:
Make sure your CSV is built as follows in one column with title NUMBER and all numbers underneath in format tel:[E164], for example tel:+3212345678.
Like so:
NUMBER
tel:[E164]
tel:[E164]
...
Then run this script:
$numberList = Import-Csv [FILEPATH]
Foreach ($num in $numberList) {
Get-CsOnlineUser | Where-Object {$_.LineURI -eq $num.NUMBER} | Select-Object UserPrincipalName, LineURI, EnterpriseVoiceEnabled, AccountEnabled}
It will take a while but it'll do the trick.
Kind regards!
- KilianTynckeCopper Contributor
Hello Ramki
You could do a Write-Host $USer.num to see what numbers you are trying to match on the -eq query. There is probably something going wrong there. It looks like your format might be off or it might be recognized as an object instead of a number.
You can do what you are trying to achieve as follows:
Make sure your CSV is built as follows in one column with title NUMBER and all numbers underneath in format tel:[E164], for example tel:+3212345678.
Like so:
NUMBER
tel:[E164]
tel:[E164]
...
Then run this script:
$numberList = Import-Csv [FILEPATH]
Foreach ($num in $numberList) {
Get-CsOnlineUser | Where-Object {$_.LineURI -eq $num.NUMBER} | Select-Object UserPrincipalName, LineURI, EnterpriseVoiceEnabled, AccountEnabled}
It will take a while but it'll do the trick.
Kind regards!- ramki1465Brass Contributorreally thaks from my bottom of heart for your guidelines.. let me excutre and come back