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.
- Loading branch information
0 parents
commit 086da32
Showing
116 changed files
with
4,462 additions
and
0 deletions.
There are no files selected for viewing
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,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
} | ||
] | ||
} |
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,37 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
$TenantFilter = (get-content Tenants.cache.json | convertfrom-json | where-object { $_.defaultdomainname -eq $Request.body.TenantFilter }).customerid | ||
$GroupName = if ($Request.body.Groupname) { $Request.body.Groupname } else { new-guid } | ||
$rawDevices = ($Request.body.Devices | convertfrom-csv -header "SerialNumber", "oemManufacturerName", "modelName", "productKey", "hardwareHash" -delimiter ",") | ||
$Devices = convertto-json @($rawDevices) | ||
|
||
$Result = try { | ||
$CurrentStatus = (New-GraphgetRequest -uri "https://api.partnercenter.microsoft.com/v1/customers/$tenantfilter/DeviceBatches" -scope 'https://api.partnercenter.microsoft.com/user_impersonation') | ||
if ($groupname -in $CurrentStatus.items.id) { throw "This device batch name already exists. Please try with another name." } | ||
$body = '{"batchId":"' + $($GroupName) + '","devices":' + $Devices + '}' | ||
$GraphRequest = (New-GraphPostRequest -uri "https://api.partnercenter.microsoft.com/v1/customers/$TenantFilter/DeviceBatches" -body $body -scope 'https://api.partnercenter.microsoft.com/user_impersonation') | ||
start-sleep 3 | ||
$NewStatus = New-GraphgetRequest -uri "https://api.partnercenter.microsoft.com/v1/customers/$tenantfilter/DeviceBatches" -scope 'https://api.partnercenter.microsoft.com/user_impersonation' | ||
if ($Newstatus.totalcount -eq $CurrentStatus.totalcount) { throw "We could not find the new autopilot device. Please check if your input is correct." } | ||
write-host $CurrentStatus.Items | ||
Log-Request -user $user -message "Created Autopilot devices group for $($Request.body.TenantFilter). Group ID is $GroupName" -Sev "Info" | ||
"Created Autopilot devices group for $($Request.body.TenantFilter). Group ID is $GroupName" | ||
} | ||
catch { | ||
"$($Request.body.TenantFilter): Failed to create autopilot devices. $($_.Exception.Message)" | ||
Log-Request -user $user -message "$($Request.body.TenantFilter): Failed to create autopilot devices. $($_.Exception.Message)" -Sev "Error" | ||
} | ||
|
||
$body = [pscustomobject]@{"Results" = $Result } | ||
write-host $body | ||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $body | ||
|
||
}) |
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,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
} | ||
] | ||
} |
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,25 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
|
||
# Interact with query parameters or the body of the request. | ||
$name = $Request.Query.Name | ||
if (-not $name) { | ||
$name = $Request.Body.Name | ||
} | ||
|
||
$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response." | ||
|
||
if ($name) { | ||
$body = "Hello, $name. This HTTP triggered function executed successfully." | ||
} | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $body | ||
}) |
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,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
} | ||
] | ||
} |
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,66 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
|
||
# Input bindings are passed in via param block. | ||
$user = $request.headers.'x-ms-client-principal' | ||
$Tenants = ($Request.body | select-object Select_*).psobject.properties.value | ||
$displayname = $request.body.Displayname | ||
$description = $request.body.Description | ||
$AssignTo = if ($request.body.Assignto -ne "on") { $request.body.Assignto } | ||
$Profbod = $Request.body | ||
$usertype = if ($Profbod.NotLocalAdmin -eq "true") { "standard" } else { "administrator" } | ||
$DeploymentMode = if($profbod.DeploymentMode -eq "true") { "shared"} else { "singleUser" } | ||
$results = foreach ($Tenant in $tenants) { | ||
try { | ||
$ObjBody = [pscustomobject]@{ | ||
"@odata.type" = "#microsoft.graph.azureADWindowsAutopilotDeploymentProfile" | ||
"displayName" = "$($displayname)" | ||
"description" = "$($description)" | ||
"deviceNameTemplate" = "$($profbod.DeviceNameTemplate)" | ||
"language" = "os-default" | ||
"enableWhiteGlove" = $([bool]($profbod.allowWhiteGlove)) | ||
"deviceType" = "windowsPc" | ||
"extractHardwareHash" = $([bool]($profbod.CollectHash)) | ||
"roleScopeTagIds" = @() | ||
"hybridAzureADJoinSkipConnectivityCheck" = $false | ||
"outOfBoxExperienceSettings" = @{ | ||
"deviceUsageType" = "$DeploymentMode" | ||
"hideEscapeLink" = $([bool]($Profbod.hideChangeAccount)) | ||
"hidePrivacySettings" = $([bool]($Profbod.hidePrivacy)) | ||
"hideEULA" = $([bool]($Profbod.hideTerms)) | ||
"userType" = "$usertype" | ||
"skipKeyboardSelectionPage" = $([bool]($Profbod.Autokeyboard)) | ||
} | ||
} | ||
$Body = convertto-json -InputObject $ObjBody | ||
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles" -body $body -tenantid $Tenant | ||
Log-Request -user $user -message "$($Tenant): Added Autopilot profile $($Displayname)" -Sev "Info" | ||
if ($AssignTo) { | ||
$AssignBody = '{"target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"}}' | ||
$assign = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$($GraphRequest.id)/assignments" -tenantid $Tenant -type POST -body $AssignBody | ||
Log-Request -user $user -message "$($Tenant): Assigned autopilot profile $($Displayname) to $AssignTo" -Sev "Info" | ||
} | ||
"Succesfully added profile for $($Tenant)<br>" | ||
} | ||
catch { | ||
"Failed to add profile for $($Tenant): $($_.Exception.Message) <br>" | ||
Log-Request -user $user -message "$($Tenant): Failed adding Autopilot Profile $($Displayname). Error: $($_.Exception.Message)" -Sev "Error" | ||
continue | ||
} | ||
|
||
} | ||
|
||
$body = [pscustomobject]@{"Results" = $results } | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $body | ||
}) | ||
|
||
|
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,15 @@ | ||
<ApplicationInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ToolVersion="1.8.3.0"> | ||
<Name>Install.ps1</Name> | ||
<UnencryptedContentSize>28057</UnencryptedContentSize> | ||
<FileName>IntunePackage.intunewin</FileName> | ||
<SetupFile>Install.ps1</SetupFile> | ||
<EncryptionInfo> | ||
<EncryptionKey>e3r9U7dd9BuuqlIXYtCN610XpMgtEhkwz9PQermN8vU=</EncryptionKey> | ||
<MacKey>JUPr6o3kWkOgJoc2WS4gLGc1eDoUwCU3gdPsIdBME2g=</MacKey> | ||
<InitializationVector>pPF597RygwVZM/gs4Oy+6w==</InitializationVector> | ||
<Mac>cC3SI059H8YWaD45oy5otYMh8dLbvTQ2N7KP6ssuS+0=</Mac> | ||
<ProfileIdentifier>ProfileVersion1</ProfileIdentifier> | ||
<FileDigest>wI1kN4fp2F2OVJT6wz1fjCJ8ulkhvxcN7c1a6+kQJu8=</FileDigest> | ||
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm> | ||
</EncryptionInfo> | ||
</ApplicationInfo> |
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,66 @@ | ||
{ | ||
|
||
"displayName": "", | ||
"installCommandLine": "", | ||
"uninstallCommandLine": "", | ||
"description": "", | ||
"developer": " ", | ||
"owner": " ", | ||
"informationUrl": " ", | ||
"privacyInformationUrl": " ", | ||
"fileName": "IntunePackage.intunewin", | ||
"@odata.type": "#microsoft.graph.win32LobApp", | ||
"applicableArchitectures": "x86, x64", | ||
|
||
"installExperience": { | ||
"runAsAccount": "user", | ||
"deviceRestartBehavior": "allow", | ||
"@odata.type": "microsoft.graph.win32LobAppInstallExperience" | ||
}, | ||
"detectionRules": [ | ||
{ | ||
"@odata.type": "#microsoft.graph.win32LobAppFileSystemDetection", | ||
"path": "%programfiles%\\7-zip", | ||
"fileOrFolderName": "7z.exe", | ||
"check32BitOn64System": false, | ||
"detectionType": "exists" } | ||
], | ||
"returncode": [ | ||
{ | ||
"returnCode": 0, | ||
"type": "success", | ||
"@odata.type": "#microsoft.graph.win32LobAppReturnCode" | ||
}, | ||
{ | ||
"returnCode": 1707, | ||
"type": "Success", | ||
"@odata.type": "#microsoft.graph.win32LobAppReturnCode" | ||
}, | ||
{ | ||
"returnCode": 1641, | ||
"type": "hardReboot", | ||
"@odata.type": "#microsoft.graph.win32LobAppReturnCode" | ||
}, | ||
{ | ||
"returnCode": 1618, | ||
"type": "retry", | ||
"@odata.type": "#microsoft.graph.win32LobAppReturnCode" | ||
}, | ||
{ | ||
"returnCode": 3010, | ||
"type": "softReboot", | ||
"@odata.type": "#microsoft.graph.win32LobAppReturnCode" | ||
} | ||
], | ||
"minimumNumberOfProcessors": "1", | ||
"minimumFreeDiskSpaceInMB": "8", | ||
"minimumCpuSpeedInMHz": "4", | ||
"minimumSupportedOperatingSystem": { | ||
"@odata.type": "microsoft.graph.windowsMinimumOperatingSystem", | ||
"v10_1607": true | ||
}, | ||
"notes": "CIPP Uploaded application", | ||
"minimumMemoryInMB": "1" | ||
|
||
|
||
} |
Binary file not shown.
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,24 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
}, | ||
{ | ||
"name": "starter", | ||
"direction": "in", | ||
"type": "durableClient" | ||
} | ||
] | ||
} |
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,47 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
$ChocoApp = $request.body | ||
$intuneBody = Get-Content "AddChocoApp\choco.app.json" | ConvertFrom-Json | ||
$assignTo = $Request.body.AssignTo | ||
$intuneBody.description = $ChocoApp.description | ||
$intuneBody.displayName = $chocoapp.ApplicationName | ||
$intuneBody.installExperience.runAsAccount = if ($ChocoApp.InstallAsSystem) { "system" } else { "user" } | ||
$intuneBody.installExperience.deviceRestartBehavior = if ($ChocoApp.DisableRestart) { "suppress" } else { "allow" } | ||
$intuneBody.installCommandLine = "powershell.exe -executionpolicy bypass .\Install.ps1 -InstallChoco -Packagename $($chocoapp.PackageName) -CustomRepo $($chocoapp.CustomRepo)" | ||
$intuneBody.UninstallCommandLine = "powershell.exe -executionpolicy bypass .\Uninstall.ps1 -Packagename $($chocoapp.PackageName)" | ||
$intunebody.detectionRules[0].path = "$($ENV:SystemDrive)\programdata\chocolatey\lib" | ||
$intunebody.detectionRules[0].fileOrFolderName = "$($chocoapp.PackageName)" | ||
|
||
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value | ||
$Results = foreach ($Tenant in $tenants) { | ||
try { | ||
$CompleteObject = [PSCustomObject]@{ | ||
tenant = $tenant | ||
Applicationname = $ChocoApp.ApplicationName | ||
assignTo = $assignTo | ||
IntuneBody = $intunebody | ||
} | ConvertTo-Json -depth 15 | ||
$JSONFile = New-Item -Path ".\ChocoApps.Cache\$(New-Guid)" -value $CompleteObject -force -erroraction Stop | ||
"Succesfully added Choco App for $($Tenant) to queue.<br>" | ||
Log-Request -user $user -message "$($Tenant): Chocolatey Application $($intunebody.Displayname) queued to add" -Sev "Info" | ||
} | ||
catch { | ||
Log-Request -user $user -message "$($Tenant): Failed to add Chocolatey Application $($intunebody.Displayname) to queue" -Sev "Error" | ||
"Failed added Choco App for $($Tenant) to queue<br>" | ||
} | ||
} | ||
|
||
$InstanceId = Start-NewOrchestration -FunctionName 'Applications_Orchestrator' | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
|
||
$body = [pscustomobject]@{"Results" = $results } | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $body | ||
}) |
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,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
} | ||
] | ||
} |
Oops, something went wrong.