Skip to content

Commit

Permalink
Merge pull request #63 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
pull[bot] authored Feb 7, 2025
2 parents 20f392b + 3e8d41f commit ddefc2b
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using namespace System.Net

function Invoke-EditIntuneScript {
<#
.FUNCTIONALITY
Entrypoint
.ROLE
Endpoint.MEM.ReadWrite
#>
[CmdletBinding()]
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
$ExecutingUser = $request.headers.'x-ms-client-principal'
Write-LogMessage -user $ExecutingUser -API $APINAME -message 'Accessed this API' -Sev Debug

$graphUrl = "https://graph.microsoft.com/beta"
switch($Request.Method) {
"GET" {
$parms = @{
uri = "$graphUrl/deviceManagement/deviceManagementScripts/$($Request.Query.ScriptId)"
tenantid = $Request.Query.TenantFilter
}

$intuneScript = New-GraphGetRequest @parms
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $intuneScript
})
}
"PATCH" {
$parms = @{
uri = "$graphUrl/deviceManagement/deviceManagementScripts/$($Request.Body.ScriptId)"
tenantid = $Request.Body.TenantFilter
body = $Request.Body.IntuneScript
}
$patchResult = New-GraphPOSTRequest @parms -type "PATCH"
$body = [pscustomobject]@{'Results' = $patchResult }
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
}
"POST" {
Write-Output "Adding script"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Function Invoke-AddStandardsTemplate {
$request.body | Add-Member -NotePropertyName 'createdAt' -NotePropertyValue ($Request.body.createdAt ? $Request.body.createdAt : (Get-Date).ToUniversalTime()) -Force
$Request.body | Add-Member -NotePropertyName 'updatedBy' -NotePropertyValue ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($request.headers.'x-ms-client-principal')) | ConvertFrom-Json).userDetails -Force
$Request.body | Add-Member -NotePropertyName 'updatedAt' -NotePropertyValue (Get-Date).ToUniversalTime() -Force
$JSON = (ConvertTo-Json -Depth 100 -InputObject ($Request.body))
$JSON = (ConvertTo-Json -Compress -Depth 100 -InputObject ($Request.body))
$Table = Get-CippTable -tablename 'templates'
$Table.Force = $true
Add-CIPPAzDataTableEntity @Table -Entity @{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,39 @@ Function Invoke-RemoveTenantAllowBlockList {
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
try {

$listType = switch -Wildcard ($request.body.entries) {
'*@*' { 'Sender'; break }
'*.*' { 'Url'; break }
default { 'FileHash' }
}
Write-Host "List type is $listType"
$ExoRequest = @{
tenantid = $Request.query.tenantfilter
tenantid = $Request.body.tenantfilter
cmdlet = 'Remove-TenantAllowBlockListItems'
cmdParams = @{
Entries = [string[]]$Request.query.entries
ListType = [string]$Request.query.listType
Entries = @($Request.body.entries)
ListType = $ListType
}
}

New-ExoRequest @ExoRequest
$Results = New-ExoRequest @ExoRequest
Write-Host $Results

$result = "Successfully removed $($Request.query.entries) from Block/Allow list"
$result = "Successfully removed $($Request.body.entries) from Block/Allow list"
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $Request.query.tenantfilter -message $result -Sev 'Info'
} catch {
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
$result = "Failed to remove $($Request.query.entries). Error: $ErrorMessage"
$result = "Failed to remove $($Request.body.entries). Error: $ErrorMessage"
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $Request.query.tenantfilter -message $result -Sev 'Error'
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = @{
'Results' = $result
'Request' = $ExoRequest
}
})
StatusCode = [HttpStatusCode]::OK
Body = @{
'Results' = $result
'Request' = $ExoRequest
}
})
}
4 changes: 4 additions & 0 deletions Modules/CIPPCore/Public/SAMManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
"id": "e330c4f0-4170-414e-a55a-2f022ec2b57b",
"type": "Role"
},
{
"id": "9255e99d-faf5-445e-bbf7-cb71482737c4",
"type": "Role"
},
{
"id": "06a5fe6d-c49d-46a7-b082-56b1b14103c7",
"type": "Role"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function Invoke-CIPPStandardSafeAttachmentPolicy {

$StateIsCorrect = ($CurrentState.Name -eq $PolicyName) -and
($CurrentState.Enable -eq $true) -and
($CurrentState.Action -eq $Settings.Action) -and
($CurrentState.Action -eq $Settings.SafeAttachmentAction) -and
($CurrentState.QuarantineTag -eq $Settings.QuarantineTag) -and
($CurrentState.Redirect -eq $Settings.Redirect) -and
(($null -eq $Settings.RedirectAddress) -or ($CurrentState.RedirectAddress -eq $Settings.RedirectAddress))
Expand All @@ -87,7 +87,7 @@ function Invoke-CIPPStandardSafeAttachmentPolicy {
} else {
$cmdparams = @{
Enable = $true
Action = $Settings.Action
Action = $Settings.SafeAttachmentAction
QuarantineTag = $Settings.QuarantineTag
Redirect = $Settings.Redirect
RedirectAddress = $Settings.RedirectAddress
Expand Down

0 comments on commit ddefc2b

Please sign in to comment.