-
Notifications
You must be signed in to change notification settings - Fork 15
/
Teams_Policy_Investigate.ps1
65 lines (44 loc) · 2.04 KB
/
Teams_Policy_Investigate.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Set-Location c:\
Clear-Host
#Install the teams module
Install-Module MicrosoftTeams -AllowClobber -Force -Verbose
#Install the MSOnline module
Install-Module MSOnline -AllowClobber -Force -Verbose
#Import the teams module
Import-Module -Name MicrosoftTeams
#Credentials
$cred = Get-Credential
#Connect to Teams
Connect-MicrosoftTeams –Credential $cred
#Connect to Microsoft 365
Connect-MsolService –Credential $cred
#Did it work
Get-MsolUser
#Did it work
Get-Team
#We need the ObjectId of a user
Get-MsolUser -UserPrincipalName "tom@tomscloud.ch" | Select-Object ObjectId
#Check the assigment for a user
Get-CsUserPolicyAssignment -Identity ba36d788-31a5-4f72-9709-7d586056762c
#Check all users for some policies
Get-CsOnlineUser | Format-Table UserPrincipalName, TeamsMessagingPolicy, TeamsMeetingPolicy, TeamsAppSetupPolicy
#The details of the policy
Get-CsTeamsMessagingPolicy -Identity "Tom"
#To grant a single user a Messaging Policy
Grant-CsTeamsMessagingPolicy -Identity fred.jonas@tomscloud.ch -PolicyName "Tom"
#Search all users in the department "Administration"
Get-CsOnlineUser -Filter {Department -eq 'Administration'} | Select UserPrincipalName
#Set a Policy for the specific users
Get-CsOnlineUser -Filter {Department -eq 'Administration'} | Grant-CsTeamsMessagingPolicy -PolicyName "Tom"
#Let's check
Get-CsOnlineUser -Filter {TeamsMessagingPolicy -eq 'Tom'} | Select UserPrincipalName
#an other way
Get-CsOnlineUser | Format-Table UserPrincipalName, TeamsMessagingPolicy, TeamsMeetingPolicy, TeamsAppSetupPolicy
#Undo
Get-CsOnlineUser -Filter {Department -eq 'Administration'} | Grant-CsTeamsMessagingPolicy -PolicyName $Null
#Other example
Get-CsOnlineUser -Filter {Department -eq 'Administration'} | Grant-CsTeamsMeetingPolicy -PolicyName $Null
#Other example
Get-CsOnlineUser -Filter {Department -eq 'Administration'} | Grant-CsTeamsAppSetupPolicy -PolicyName $Null
#Remove a policy from a user
Grant-CsTeamsMessagingPolicy -Identity fred.jonas@tomscloud.ch -PolicyName $null