Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using namespace System.Net

Function Invoke-ExecUpdateSecureScore {
function Invoke-ExecUpdateSecureScore {
<#
.FUNCTIONALITY
Entrypoint
Expand All @@ -17,23 +17,28 @@ Function Invoke-ExecUpdateSecureScore {
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Body.TenantFilter
$ControlName = $Request.Body.ControlName
$Body = @{
comment = $Request.Body.reason
state = $Request.Body.resolutionType.value
vendorInformation = $Request.Body.vendorInformation
}
try {
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/security/secureScoreControlProfiles/$ControlName" -tenantid $TenantFilter -type PATCH -Body (ConvertTo-Json -InputObject $Body -Compress)
$StatusCode = [HttpStatusCode]::OK
$Result = "Successfully set control $ControlName to $($Body.state)"
Write-LogMessage -headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev 'Info'
} catch {
$ErrorMessage = Get-CippException -Exception $_
$Result = "Failed to set control $ControlName to $($Body.state). Error: $($ErrorMessage.NormalizedError)"
Write-LogMessage -headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev Error -LogData $ErrorMessage
$StatusCode = [HttpStatusCode]::InternalServerError
}

if ($ControlName -match '^scid_') {
$Result = 'Defender controls cannot be updated via this API. Please use the Microsoft 365 Defender portal to update these controls.'
$StatusCode = [HttpStatusCode]::BadRequest
} else {
$Body = @{
comment = $Request.Body.reason
state = $Request.Body.resolutionType.value
vendorInformation = $Request.Body.vendorInformation
}
try {
$null = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/security/secureScoreControlProfiles/$ControlName" -tenantid $TenantFilter -type PATCH -Body (ConvertTo-Json -InputObject $Body -Compress)
$StatusCode = [HttpStatusCode]::OK
$Result = "Successfully set control $ControlName to $($Body.state)"
Write-LogMessage -headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev 'Info'
} catch {
$ErrorMessage = Get-CippException -Exception $_
$Result = "Failed to set control $ControlName to $($Body.state). Error: $($ErrorMessage.NormalizedError)"
Write-LogMessage -headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev Error -LogData $ErrorMessage
$StatusCode = [HttpStatusCode]::InternalServerError
}
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = $StatusCode
Expand Down