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.
Merge pull request #63 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
- Loading branch information
Showing
5 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-EditIntuneScript.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,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" | ||
} | ||
} | ||
} |
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
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
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
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