question

MS-5605 avatar image
0 Votes"
MS-5605 asked NewbieJones-6218 answered

How to filter users based on the location (PowerShell)

Hi,

I run the following script to export the users' list and their information. Is there a way to filter out only based on the county multiple usage locations (example: IN, US, UK, DE and JP).?



$Users = invoke-command -ScriptBlock {(Get-CsOnlineUser -Filter {(AssignedPlan -eq 'Teams') -and (accountenabled -eq $True)} -ResultSize 50000) | Where-Object {$_.SoftDeletionTimeStamp -eq $null} | Select-Object `
UserPrincipalName, SipAddress, OnPremLineUri, LineUri, City}



thank you,

Regards,
MS

office-teams-windows-itprooffice-teams-app-dev
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @MS-5605

Thank you for your post.

I hope this is what you are looking for so, see it below:

https://docs.microsoft.com/en-us/powershell/module/skype/set-csonlinelislocation?msclkid=5729f1f6ce8a11ec871c1d89dc222199&view=skype-ps

BR,

Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 Votes 0 ·
MS-5605 avatar image MS-5605 ricardosolisvillegas-4678 ·

Thank you. But I want to add multiple locations in the script for now i am able to export "UsageLocation for US (UsageLocation -eq 'US)", how do add more usage locations in the script?



Get-CsOnlineUser -Filter {(AssignedPlan -eq 'Teams') -and (accountenabled -eq $True) -and (UsageLocation -eq 'US')} -ResultSize 10 | Where-Object {$_.SoftDeletionTimeStamp -eq $null} | Select-Object `
UserPrincipalName, SipAddress, OnPremLineUri, LineUri, City

Thanks,
MS

0 Votes 0 ·

Hi @MS-5605

Do you mean you want to add another UserLocation such as Japan,UK in your script?

Teams forum is mainly focused on the general issue of Microsoft Teams troubleshooting. According to your description. your question is also related to PowerShell script development, so I will also add teams-app-dev tag to your thread. Thanks for your understanding!

0 Votes 0 ·
geruni-5550 avatar image geruni-5550 ricardosolisvillegas-4678 ·

tell me, do you mean adding a location to the script as in this example?
bwin


0 Votes 0 ·

@geruni-5550 . Yes, Not sure how to add multiple locations to this filter (UsageLocation -eq 'US')..

Thank you so much.

0 Votes 0 ·

@MS-5605 - Is this related to Teams App development?
For questions related to Powershell Microsoft PowerShell Community forum


0 Votes 0 ·
JimmyYang-MSFT avatar image JimmyYang-MSFT Nivedipa-MSFT-6619 ·

@MS-5605
Teams tag is mainly focused on the general issue of Microsoft Teams troubleshooting. Considering your question is also related to PowerShell command, we also recommend you add the tag "windows-server-powershell". Thanks for your understanding and patience!

0 Votes 0 ·

@MS-5605

It has been a while, how is everything going?

0 Votes 0 ·

1 Answer

NewbieJones-6218 avatar image
0 Votes"
NewbieJones-6218 answered

A bit late, but as this didn't seem to get answered. You just need to add OR statements to your filter.

For example..

 Get-CsOnlineUser -Filter {(AssignedPlan -eq 'Teams') -and (accountenabled -eq $True) -and ((UsageLocation -eq 'US') -or (UsageLocation -eq 'JP') -or (UsageLocation -eq 'UK'))} -ResultSize 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.