Skip to content

Commit

Permalink
Merge pull request #1296 from redanthrax/IntuneScripts
Browse files Browse the repository at this point in the history
Intune Script Edit
  • Loading branch information
KelvinTegelaar authored Feb 7, 2025
2 parents b7acf48 + 334ee85 commit 1026a49
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 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"
}
}
}
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

0 comments on commit 1026a49

Please sign in to comment.