{"id":2851,"date":"2023-03-06T17:16:41","date_gmt":"2023-03-06T17:16:41","guid":{"rendered":"https:\/\/modern-workplace.uk\/?p=2851"},"modified":"2023-03-07T11:35:41","modified_gmt":"2023-03-07T11:35:41","slug":"teams-virtual-sbc-closing-azure-network-ports-warnings-for-azureloadbalancer-and-virtualnetwork-2-2-2-2-3-2-3-2-2-2-2-2-3-2-2-3-2-3-2-2-2-4-3","status":"publish","type":"post","link":"https:\/\/modern-workplace.uk\/?p=2851","title":{"rendered":"Microsoft Teams &#8211; Using Get-CsOnlineUser with Filters (Microsoft Teams PowerShell 5.0.0)"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>The <strong>Get-CsOnlineUser <\/strong>PowerShell cmdlet is a powerful tool that enables you to retrieve information about your Teams users, and with the Teams PowerShell Module 5.0.0 it has been updated with new features and performance improvements to make managing your Teams users even easier (see the <a rel=\"noreferrer noopener\" href=\"https:\/\/learn.microsoft.com\/en-us\/microsoftteams\/teams-powershell-release-notes\" data-type=\"URL\" data-id=\"https:\/\/learn.microsoft.com\/en-us\/microsoftteams\/teams-powershell-release-notes\" target=\"_blank\">Release Notes<\/a> here)<\/p>\n\n\n\n<p>In this blog post, I will explore the latest enhancements to the Get-CsOnlineUser cmdlet, including significant performance improvements and new filtering capabilities that allow you to retrieve information more efficiently. I will also provide examples of how to use the new attributes as filters in your PowerShell scripts to get the information you need about your Teams users.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Performance Improvements<\/strong><br>The image is get-csonlineuser from version 4.9.3 (above) and from version 5.0.0 (below). The test was from the same workstation and on the same tenant. The required time goes down from 34 seconds to 8<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/PowerShell5_0_0.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"472\" height=\"450\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/PowerShell5_0_0.jpg\" alt=\"\" class=\"wp-image-2852\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/PowerShell5_0_0.jpg 472w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/PowerShell5_0_0-300x286.jpg 300w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Use the New Attributes as Filters in your PowerShell Scripts<\/strong><\/p>\n\n\n\n<p>At the moment two attributes quoted in the documentation are wrong compared to what you get from the tenant<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">CompanyName should be Company<br>State should be StateOrProvince<\/p>\n\n\n\n<p>Note: In the examples I have just created a list of users that match the filter.<\/p>\n\n\n\n<p>This command will retrieve all users who are located in the state of Washington, and in any city that contains &#8220;Bell&#8221; in its name<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {Stateorprovince -eq \"WA\" -and City -like \"Bell\"} | ft userprincipalname<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"935\" height=\"97\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1.jpg\" alt=\"\" class=\"wp-image-2853\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1.jpg 935w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1-300x31.jpg 300w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1-768x80.jpg 768w\" sizes=\"auto, (max-width: 935px) 100vw, 935px\" \/><\/a><\/figure>\n\n\n\n<p>This command will retrieve all users who have the &#8220;PhoneSystem&#8221; feature enabled<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {FeatureTypes -contains \"PhoneSystem\"} | ft userprincipalname<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1_feature.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"823\" height=\"334\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1_feature.jpg\" alt=\"\" class=\"wp-image-2854\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1_feature.jpg 823w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1_feature-300x122.jpg 300w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2023\/03\/Module5_0_0_1_feature-768x312.jpg 768w\" sizes=\"auto, (max-width: 823px) 100vw, 823px\" \/><\/a><\/figure>\n\n\n\n<p>This command will retrieve all users who were created between January 1st and March 6th, 2023<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {WhenCreated -gt \"2023-01-01T00:00:00Z\" -and WhenCreated -lt \"2023-03-06T23:59:59Z\"} | ft userprincipalname<\/code><\/pre>\n\n\n\n<p>This command will retrieve all users whose SipProxyAddress contains &#8220;m365x01033383.onmicrosoft.com&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {SipProxyAddress -like \"*m365x01033383.onmicrosoft.com\"} | ft userprincipalname<\/code><\/pre>\n\n\n\n<p>This command will retrieve all users whose CompanyName is &#8220;Contoso&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {Company -eq \"Contoso\"}<\/code><\/pre>\n\n\n\n<p>This command will retrieve all users whose HostingProvider is set to &#8221; sipfed.online.lync.com&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {HostingProvider -eq \"sipfed.online.lync.com\"} | ft userprincipalname<\/code><\/pre>\n\n\n\n<p>This command will retrieve all users whose Alias contains &#8220;John&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {Alias -like \"*john*\"}<\/code><\/pre>\n\n\n\n<p>This command will retrieve all soft deleted users who were deleted after January 1st, 2023<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {SoftDeletionTimestamp -gt \"2023-01-01T00:00:00Z\"}<\/code><\/pre>\n\n\n\n<p>This command will retrieve all users whose PreferredDataLocation is set to &#8220;EUR&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {PreferredDataLocation -eq \"EUR\"}<\/code><\/pre>\n\n\n\n<p>This command will retrieve all users whose LastName is &#8220;Vance&#8221;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CsOnlineUser -Filter {LastName -eq \"Vance\"}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Get-CsOnlineUser PowerShell cmdlet is a powerful tool that enables you to retrieve information about your Teams users, and with the Teams PowerShell Module 5.0.0 it has been updated with new features and performance improvements to make managing your Teams users even easier (see the Release Notes here)<\/p>\n<p>In this blog post, I will explore the latest enhancements to the Get-CsOnlineUser cmdlet, including significant performance improvements and new filtering capabilities that allow you to retrieve information more efficiently. I will also provide examples of how to use the new attributes as filters in your PowerShell scripts to get the information you need about your Teams users<\/p>\n","protected":false},"author":1,"featured_media":2857,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","twitterCardType":"","cardImageID":0,"cardImage":"","cardTitle":"","cardDesc":"","cardImageAlt":"","cardPlayer":"","cardPlayerWidth":0,"cardPlayerHeight":0,"cardPlayerStream":"","cardPlayerCodec":"","footnotes":""},"categories":[810,753,752,757],"tags":[762,759,751,77,755,83],"class_list":["post-2851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-810","category-microsoft365","category-microsoft-teams","category-office-365","tag-microsoftteams","tag-microsoft-365","tag-microsoft-teams","tag-office-365","tag-teams","tag-voice"],"_links":{"self":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts\/2851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2851"}],"version-history":[{"count":1,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts\/2851\/revisions"}],"predecessor-version":[{"id":2858,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts\/2851\/revisions\/2858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/media\/2857"}],"wp:attachment":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}