Skip to content

Commit 2319073

Browse files
committed
Feat:: New Teams Chat Protection settings standard
1 parent 440f5f2 commit 2319073

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
function Invoke-CIPPStandardTeamsChatProtection {
2+
<#
3+
.FUNCTIONALITY
4+
Internal
5+
.COMPONENT
6+
(APIName) TeamsChatProtection
7+
.SYNOPSIS
8+
(Label) Teams Chat Protection Settings
9+
.DESCRIPTION
10+
(Helptext) Configures Teams chat protection settings including weaponizable file protection and malicious URL protection.
11+
(DocsDescription) Configures Teams messaging safety features to protect users from weaponizable files and malicious URLs in chats and channels. Weaponizable File Protection automatically blocks messages containing potentially dangerous file types (like .exe, .dll, .bat, etc.). Malicious URL Protection scans URLs in messages and displays warnings when potentially harmful links are detected. These protections work across internal and external collaboration scenarios.
12+
.NOTES
13+
CAT
14+
Teams Standards
15+
TAG
16+
17+
ADDEDCOMPONENT
18+
{"type":"switch","name":"standards.TeamsChatProtection.FileTypeCheck","label":"Enable Weaponizable File Protection","defaultValue":true}
19+
{"type":"switch","name":"standards.TeamsChatProtection.UrlReputationCheck","label":"Enable Malicious URL Protection","defaultValue":true}
20+
IMPACT
21+
Low Impact
22+
ADDEDDATE
23+
2025-10-02
24+
POWERSHELLEQUIVALENT
25+
Set-CsTeamsMessagingConfiguration
26+
RECOMMENDEDBY
27+
CIS
28+
UPDATECOMMENTBLOCK
29+
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
30+
.LINK
31+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards
32+
#>
33+
34+
param($Tenant, $Settings)
35+
$TestResult = Test-CIPPStandardLicense -StandardName 'TeamsChatProtection' -TenantFilter $Tenant -RequiredCapabilities @('MCOSTANDARD', 'MCOEV', 'MCOIMP', 'TEAMS1', 'Teams_Room_Standard')
36+
37+
if ($TestResult -eq $false) {
38+
Write-Host "We're exiting as the correct license is not present for this standard."
39+
return $true
40+
} #we're done.
41+
42+
try {
43+
$CurrentState = New-TeamsRequest -TenantFilter $Tenant -Cmdlet 'Get-CsTeamsMessagingConfiguration' | Select-Object -Property Identity, FileTypeCheck, UrlReputationCheck
44+
} catch {
45+
$ErrorMessage = Get-CippException -Exception $_
46+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Could not get the Teams Chat Protection state for $Tenant. Error: $($ErrorMessage.NormalizedError)" -Sev Error -LogData $ErrorMessage
47+
return
48+
}
49+
50+
# Set defaults to enabled if not specified
51+
$Settings.FileTypeCheck ??= $true
52+
$Settings.UrlReputationCheck ??= $true
53+
54+
# Convert boolean to Enabled/Disabled string
55+
$FileTypeCheckState = $Settings.FileTypeCheck ? 'Enabled' : 'Disabled'
56+
$UrlReputationCheckState = $Settings.UrlReputationCheck ? 'Enabled' : 'Disabled'
57+
58+
$StateIsCorrect = ($CurrentState.FileTypeCheck -eq $FileTypeCheckState) -and
59+
($CurrentState.UrlReputationCheck -eq $UrlReputationCheckState)
60+
61+
if ($Settings.remediate -eq $true) {
62+
if ($StateIsCorrect -eq $true) {
63+
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Teams Chat Protection settings already correctly configured.' -sev Info
64+
} else {
65+
$cmdParams = @{
66+
Identity = 'Global'
67+
FileTypeCheck = $FileTypeCheckState
68+
UrlReputationCheck = $UrlReputationCheckState
69+
}
70+
71+
try {
72+
$null = New-TeamsRequest -TenantFilter $Tenant -Cmdlet 'Set-CsTeamsMessagingConfiguration' -CmdParams $cmdParams
73+
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Successfully updated Teams Chat Protection settings to FileTypeCheck: $FileTypeCheckState, UrlReputationCheck: $UrlReputationCheckState" -sev Info
74+
} catch {
75+
$ErrorMessage = Get-CippException -Exception $_
76+
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to configure Teams Chat Protection settings. Error: $($ErrorMessage.NormalizedError)" -sev Error -LogData $ErrorMessage
77+
}
78+
}
79+
}
80+
81+
if ($Settings.alert -eq $true) {
82+
if ($StateIsCorrect -eq $true) {
83+
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Teams Chat Protection settings are configured correctly.' -sev Info
84+
} else {
85+
Write-StandardsAlert -message 'Teams Chat Protection settings are not configured correctly.' -object $CurrentState -tenant $Tenant -standardName 'TeamsChatProtection' -standardId $Settings.standardId
86+
Write-LogMessage -API 'Standards' -tenant $Tenant -message 'Teams Chat Protection settings are not configured correctly.' -sev Info
87+
}
88+
}
89+
90+
if ($Settings.report -eq $true) {
91+
Add-CIPPBPAField -FieldName 'TeamsChatProtection' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $Tenant
92+
93+
if ($StateIsCorrect) {
94+
$FieldValue = $true
95+
} else {
96+
$FieldValue = $CurrentState
97+
}
98+
Set-CIPPStandardsCompareField -FieldName 'standards.TeamsChatProtection' -FieldValue $FieldValue -Tenant $Tenant
99+
}
100+
}

0 commit comments

Comments
 (0)