Skip to content

Commit

Permalink
Merge pull request #17 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
kris6673 authored Mar 16, 2024
2 parents dd99d6a + 7707162 commit a41950d
Show file tree
Hide file tree
Showing 44 changed files with 513 additions and 603 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/dev_cippckdtz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Powershell project to Azure Function App - cippckdtz

on:
push:
branches:
- dev
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
deploy:
runs-on: windows-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cippckdtz'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_2101C7175BFB47E58240ABD1E72E81C2 }}
16 changes: 0 additions & 16 deletions ExecExtensionNinjaOneQueue/function.json

This file was deleted.

13 changes: 0 additions & 13 deletions ExecExtensionNinjaOneQueue/run.ps1

This file was deleted.

7 changes: 3 additions & 4 deletions ExecGDAPInviteApproved_Timer/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
"schedule": "0 0 */3 * * *"
},
{
"type": "queue",
"direction": "out",
"name": "gdapinvitequeue",
"queueName": "gdapinvitequeue"
"name": "starter",
"type": "durableClient",
"direction": "in"
}
]
}
10 changes: 0 additions & 10 deletions ExecGDAPInviteQueue/function.json

This file was deleted.

7 changes: 0 additions & 7 deletions ExecGDAPInviteQueue/run.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions ListLicensesAllTenants/function.json

This file was deleted.

28 changes: 0 additions & 28 deletions ListLicensesAllTenants/run.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions ListMFAUsersAllTenants/function.json

This file was deleted.

57 changes: 0 additions & 57 deletions ListMFAUsersAllTenants/run.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions ListMailboxRulesAllTenants/function.json

This file was deleted.

2 changes: 1 addition & 1 deletion Modules/CIPPCore/Public/Add-CIPPGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Add-CIPPGroupMember(
} else {
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($GroupId)" -tenantid $TenantFilter -type patch -body $addmemberbody -Verbose
}
$Message = "Successfully added user $($Member) to $GroupId."
$Message = "Successfully added user $($Member) to $($GroupId)."
Write-LogMessage -user $ExecutingUser -API $APIName -tenant $TenantFilter -message $Message -Sev 'Info'
return $message
return
Expand Down
116 changes: 62 additions & 54 deletions Modules/CIPPCore/Public/Entrypoints/Invoke-ExecExtensionMapping.ps1
Original file line number Diff line number Diff line change
@@ -1,81 +1,89 @@
using namespace System.Net
using namespace System.Net

Function Invoke-ExecExtensionMapping {
Function Invoke-ExecExtensionMapping {
<#
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
param($Request, $TriggerMetadata)

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


# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
$Table = Get-CIPPTable -TableName CippMapping
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
$Table = Get-CIPPTable -TableName CippMapping

if ($Request.Query.List) {
switch ($Request.Query.List) {
'Halo' {
$body = Get-HaloMapping -CIPPMapping $Table
}

'NinjaOrgs' {
$Body = Get-NinjaOneOrgMapping -CIPPMapping $Table
}

'NinjaFields' {
$Body = Get-NinjaOneFieldMapping -CIPPMapping $Table

}
}
}

try {
if ($Request.Query.AddMapping) {
switch ($Request.Query.AddMapping) {
if ($Request.Query.List) {
switch ($Request.Query.List) {
'Halo' {
$body = Set-HaloMapping -CIPPMapping $Table -APIName $APIName -Request $Request
$body = Get-HaloMapping -CIPPMapping $Table
}

'NinjaOrgs' {
$Body = Set-NinjaOneOrgMapping -CIPPMapping $Table -APIName $APIName -Request $Request
$Body = Get-NinjaOneOrgMapping -CIPPMapping $Table
}

'NinjaFields' {
$Body = Set-NinjaOneFieldMapping -CIPPMapping $Table -APIName $APIName -Request $Request -TriggerMetadata $TriggerMetadata
$Body = Get-NinjaOneFieldMapping -CIPPMapping $Table

}
}
}
}
catch {
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "mapping API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}

try {
if ($Request.Query.AutoMapping) {
switch ($Request.Query.AutoMapping) {
'NinjaOrgs' {
Push-OutputBinding -Name NinjaProcess -Value @{'NinjaAction' = 'StartAutoMapping' }
$Body = [pscustomobject]@{'Results' = 'Automapping Request has been queued. Exact name matches will appear first and matches on device names and serials will take longer. Please check the CIPP Logbook and refresh the page once complete.' }
}
try {
if ($Request.Query.AddMapping) {
switch ($Request.Query.AddMapping) {
'Halo' {
$body = Set-HaloMapping -CIPPMapping $Table -APIName $APIName -Request $Request
}

'NinjaOrgs' {
$Body = Set-NinjaOneOrgMapping -CIPPMapping $Table -APIName $APIName -Request $Request
}

'NinjaFields' {
$Body = Set-NinjaOneFieldMapping -CIPPMapping $Table -APIName $APIName -Request $Request -TriggerMetadata $TriggerMetadata
}
}
}
} catch {
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "mapping API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}
}
catch {
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "mapping API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
try {
if ($Request.Query.AutoMapping) {
switch ($Request.Query.AutoMapping) {
'NinjaOrgs' {
#Push-OutputBinding -Name NinjaProcess -Value @{'NinjaAction' = 'StartAutoMapping' }
$Batch = [PSCustomObject]@{
'NinjaAction' = 'StartAutoMapping'
'FunctionName' = 'NinjaOneQueue'
}
$InputObject = [PSCustomObject]@{
OrchestratorName = 'NinjaOneOrchestrator'
Batch = @($Batch)
}
#Write-Host ($InputObject | ConvertTo-Json)
$InstanceId = Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5)
Write-Host "Started permissions orchestration with ID = '$InstanceId'"
$Body = [pscustomobject]@{'Results' = 'Automapping Request has been queued. Exact name matches will appear first and matches on device names and serials will take longer. Please check the CIPP Logbook and refresh the page once complete.' }
}

}
}
} catch {
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "mapping API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})

}
Loading

0 comments on commit a41950d

Please sign in to comment.