|
1 | | -using namespace System.Net |
2 | | - |
3 | | -function Invoke-EditIntuneScript { |
4 | | - <# |
5 | | - .FUNCTIONALITY |
6 | | - Entrypoint |
7 | | - .ROLE |
8 | | - Endpoint.MEM.ReadWrite |
9 | | - #> |
10 | | - [CmdletBinding()] |
11 | | - param($Request, $TriggerMetadata) |
12 | | - |
13 | | - $APIName = $Request.Params.CIPPEndpoint |
14 | | - $Headers = $Request.Headers |
15 | | - Write-LogMessage -Headers $Headers -API $APINAME -message 'Accessed this API' -Sev Debug |
16 | | - |
17 | | - $graphUrl = "https://graph.microsoft.com/beta" |
18 | | - switch($Request.Method) { |
19 | | - "GET" { |
20 | | - $parms = @{ |
21 | | - uri = "$graphUrl/deviceManagement/deviceManagementScripts/$($Request.Query.ScriptId)" |
22 | | - tenantid = $Request.Query.TenantFilter |
23 | | - } |
24 | | - |
25 | | - $intuneScript = New-GraphGetRequest @parms |
26 | | - Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ |
27 | | - StatusCode = [HttpStatusCode]::OK |
28 | | - Body = $intuneScript |
29 | | - }) |
30 | | - } |
31 | | - "PATCH" { |
32 | | - $parms = @{ |
33 | | - uri = "$graphUrl/deviceManagement/deviceManagementScripts/$($Request.Body.ScriptId)" |
34 | | - tenantid = $Request.Body.TenantFilter |
35 | | - body = $Request.Body.IntuneScript |
36 | | - } |
37 | | - $patchResult = New-GraphPOSTRequest @parms -type "PATCH" |
38 | | - $body = [pscustomobject]@{'Results' = $patchResult } |
39 | | - Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ |
40 | | - StatusCode = [HttpStatusCode]::OK |
41 | | - Body = $body |
42 | | - }) |
43 | | - } |
44 | | - "POST" { |
45 | | - Write-Output "Adding script" |
46 | | - } |
47 | | - } |
48 | | -} |
| 1 | +using namespace System.Net |
| 2 | + |
| 3 | +function Invoke-EditIntuneScript { |
| 4 | + <# |
| 5 | + .FUNCTIONALITY |
| 6 | + Entrypoint |
| 7 | + .ROLE |
| 8 | + Endpoint.MEM.ReadWrite |
| 9 | + #> |
| 10 | + [CmdletBinding()] |
| 11 | + param($Request, $TriggerMetadata) |
| 12 | + |
| 13 | + $APIName = $Request.Params.CIPPEndpoint |
| 14 | + $Headers = $Request.Headers |
| 15 | + Write-LogMessage -Headers $Headers -API $APINAME -message 'Accessed this API' -Sev Debug |
| 16 | + |
| 17 | + $graphUrl = "https://graph.microsoft.com/beta" |
| 18 | + switch($Request.Method) { |
| 19 | + "GET" { |
| 20 | + $parms = @{ |
| 21 | + uri = "$graphUrl/deviceManagement/deviceManagementScripts/$($Request.Query.ScriptId)" |
| 22 | + tenantid = $Request.Query.TenantFilter |
| 23 | + } |
| 24 | + |
| 25 | + $intuneScript = New-GraphGetRequest @parms |
| 26 | + Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ |
| 27 | + StatusCode = [HttpStatusCode]::OK |
| 28 | + Body = $intuneScript |
| 29 | + }) |
| 30 | + } |
| 31 | + "PATCH" { |
| 32 | + $parms = @{ |
| 33 | + uri = "$graphUrl/deviceManagement/deviceManagementScripts/$($Request.Body.ScriptId)" |
| 34 | + tenantid = $Request.Body.TenantFilter |
| 35 | + body = $Request.Body.IntuneScript |
| 36 | + } |
| 37 | + $patchResult = New-GraphPOSTRequest @parms -type "PATCH" |
| 38 | + $body = [pscustomobject]@{'Results' = $patchResult } |
| 39 | + Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ |
| 40 | + StatusCode = [HttpStatusCode]::OK |
| 41 | + Body = $body |
| 42 | + }) |
| 43 | + } |
| 44 | + "POST" { |
| 45 | + Write-Output "Adding script" |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments