forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d3ace5
commit f9e1151
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Modules/CIPPCore/Public/GraphHelper/New-TeamsAPIPOSTRequest.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function New-TeamsAPIPOSTRequest { | ||
<# | ||
.FUNCTIONALITY | ||
Internal | ||
#> | ||
Param( | ||
$uri, | ||
$tenantid, | ||
$body, | ||
$method = 'PUT', | ||
$Resource = '48ac35b8-9aa8-4d74-927d-1f4a14a0b239' | ||
) | ||
|
||
if ((Get-AuthorisedRequest -Uri $uri -TenantID $tenantid)) { | ||
$token = Get-ClassicAPIToken -Tenant $tenantid -Resource $Resource | ||
|
||
$headers = @{ | ||
Authorization = "Bearer $($token.access_token)" | ||
'x-ms-client-request-id' = [guid]::NewGuid().ToString() | ||
'x-ms-client-session-id' = [guid]::NewGuid().ToString() | ||
'x-ms-correlation-id' = [guid]::NewGuid() | ||
'X-Requested-With' = 'XMLHttpRequest' | ||
'x-ms-tnm-applicationid' = '045268c0-445e-4ac1-9157-d58f67b167d9' | ||
} | ||
|
||
try { | ||
$Data = Invoke-RestMethod -Uri $uri -Method $method -Body $body -ContentType 'application/json; charset=utf-8' -Headers $headers | ||
} catch [System.Net.WebException] { | ||
Write-LogMessage -API 'Standards' -Tenant $tenant -message "Teams API Post Request failed. Error: $($_.exception.message)" -sev Error | ||
|
||
$Message = if ($_.ErrorDetails.Message) { | ||
Get-NormalizedError -Message $_.ErrorDetails.Message | ||
} else { | ||
$_.Exception.message | ||
} | ||
throw $Message | ||
} | ||
return $Data | ||
} else { | ||
Write-Error 'Not allowed. You cannot manage your own tenant or tenants not under your scope' | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardConfigureTeamsThirdPartyFiles.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
function Invoke-CIPPStandardConfigureTeamsThirdPartyFiles { | ||
<# | ||
.FUNCTIONALITY | ||
Internal | ||
#> | ||
|
||
param($Tenant, $Settings) | ||
$CurrentSetting = New-TeamsAPIGetRequest -Uri "https://api.interfaces.records.teams.microsoft.com/Skype.Policy/Tenants/$($Tenant)/configurations/TeamsClientConfiguration/configuration/Global" -tenantid $tenant | | ||
Select-Object AllowShareFile, AllowDropBox, AllowBox, AllowGoogleDrive, AllowEgnyte | ||
|
||
$StateIsCorrect = $CurrentSetting.AllowShareFile -eq $Settings.AllowShareFile -and | ||
$CurrentSetting.AllowDropBox -eq $Settings.AllowDropBox -and | ||
$CurrentSetting.AllowBox -eq $Settings.AllowBox -and | ||
$CurrentSetting.AllowGoogleDrive -eq $Settings.AllowGoogleDrive -and | ||
$CurrentSetting.AllowEgnyte -eq $Settings.AllowEgnyte | ||
|
||
if ($Settings.remediate) { | ||
if ($StateIsCorrect) { | ||
Write-LogMessage -API 'Standards' -Tenant $tenant -message 'Microsoft Teams Third Party Files are already configured.' -sev Info | ||
} else { | ||
Write-LogMessage -API 'Standards' -Tenant $tenant -message 'Remediating Microsoft Teams Third Party Files.' -sev Info | ||
$body = @{ | ||
"AllowShareFile" = $Settings.AllowShareFile | ||
"AllowDropBox" = $Settings.AllowDropBox | ||
"AllowBox" = $Settings.AllowBox | ||
"AllowGoogleDrive" = $Settings.AllowGoogleDrive | ||
"AllowEgnyte" = $Settings.AllowEgnyte | ||
} | ||
|
||
try { | ||
$params = @{ | ||
Uri = "https://api.interfaces.records.teams.microsoft.com/Skype.Policy/Tenants/$($Tenant)/configurations/TeamsClientConfiguration/configuration/Global" | ||
TenantId = $tenant | ||
Body = $body | ||
} | ||
New-TeamsAPIPOSTRequest @params | ||
} catch { | ||
Write-LogMessage -API 'Standards' -Tenant $tenant -message "Failed to set Microsoft Teams Third Party Files settings. Error: $($_.exception.message)" -sev Error | ||
} | ||
} | ||
} | ||
|
||
if ($Settings.alert) { | ||
if ($StateIsCorrect) { | ||
Write-LogMessage -API 'Standards' -Tenant $tenant -message 'Microsoft Teams Third Party Files are configured.' -sev Info | ||
} else { | ||
Write-LogMessage -API 'Standards' -Tenant $tenant -message 'Microsoft Teams Third Party Files are not configured.' -sev Alert | ||
} | ||
} | ||
|
||
if ($Settings.report) { | ||
Add-CIPPBPAField -FieldName 'TeamsThirdPartyFiles' -FieldValue [bool]$StateIsCorrect -StoreAs bool -Tenant $tenant | ||
} | ||
} |