Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
Last active May 28, 2021 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmatthews05/0165fbc6ccb91e53a2e26efea1f02156 to your computer and use it in GitHub Desktop.
Save pmatthews05/0165fbc6ccb91e53a2e26efea1f02156 to your computer and use it in GitHub Desktop.
Write-host "Teams Meeting Policy"
Get-CsOnlineUser -Filter {TeamsMeetingPolicy -eq 'GivenPolicyNameBlankForGlobal'} | Select UserPrincipalName
@garbertschow
Copy link

Hey, I got the following issue when I wanna check for Users who are in Global Policies. What do you mean by:
GivenPolicyNameBlankForGlobal
Neither of those work for me:
Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq ""} | Select UserPrincipalName
Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq " "} | Select UserPrincipalName
Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq "Global"} | Select UserPrincipalName

Errorcode is: The policy "" is not a Userpolicy.

@pmatthews05
Copy link
Author

Hi @garberschow,
Can I check, are you still using the SkypeForBusiness module, or the Teams Module now. That blog post is a bit out of date now.

Get-CsOnlineUser doesn't seem to be in the new MS Teams Module. With the 10 minutes I have spare, I'm unable to find out what the replacement of this is.

Other thing, perhaps you can try, is use single quote instead of double?

@garbertschow
Copy link

garbertschow commented May 27, 2021

Hey I tried using single quotes too. I am using the Teams Module. Although I got some commands working Get-CsOnlineUser
EDIT: For example Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq "INSERTCUSTOMGROUPNAMEHERE"} | Select UserPrincipalName
works just fine

@pmatthews05
Copy link
Author

Unable to look at, at the moment. I was unable to find the command Get-CsOnlineUser when I tested at lunch time.

When I said 'GivenPolicyNameBlankForGlobal' I meant give a policy name, OR put blank for global, but as you have stated that didn't work.

Which version of Teams module are you using. I will attempt to have a go later on tonight, and report back. Any chance you could post your code for this bit?

@garbertschow
Copy link

Version 2.3.1 MicrosoftTeams
The Code is just:
Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq ""} | Select UserPrincipalName
I also tried:
Get-CsOnlineUser -WarningAction SilentlyContinue | Where-Object { $_.TeamsAppPermissionPolicy -eq ""} | Select UserPrincipalName

And this line works as intended:
Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq "Global NoApps"} | Select UserPrincipalName

Thank you for your help!

@pmatthews05
Copy link
Author

Cheers, I will take a look later. You connect like below?

Install-Module MicrosoftTeams
$credential = Get-Credential
#Connect to Microsoft Teams
Connect-MicrosoftTeams -Credential $credential
Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq "Global NoApps"} | Select UserPrincipalName

One last thought, you haven't removed/deleted the original Global policy?

@pmatthews05
Copy link
Author

I think for the Teams Module they have updated this code. So you use $null instead of blank or Global.

Get-CsOnlineUser -Filter {TeamsAppPermissionPolicy -eq $null} | Select UserPrincipalName

Let me know if that works for you.

@garbertschow
Copy link

Thank you so far. I will try tomorrow and report back. Have a nice day.

@garbertschow
Copy link

$null works! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment