Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#422 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
KelvinTegelaar authored Sep 25, 2023
2 parents eafc8a0 + ee3fb18 commit 7420a97
Show file tree
Hide file tree
Showing 39 changed files with 723 additions and 367 deletions.
14 changes: 6 additions & 8 deletions AddAlert/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
"methods": ["get", "post"]
},
{
"type": "http",
"direction": "out",
"name": "Response"
},
{
"name": "starter",
"direction": "in",
"type": "durableClient"
"type": "queue",
"direction": "out",
"name": "Subscription",
"queueName": "AlertSubscriptions"
}
]
}
}
11 changes: 4 additions & 7 deletions AddAlert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ $Results = foreach ($Tenant in $tenants) {
try {
$TenantID = if ($tenant -ne 'AllTenants') {
(get-tenants | Where-Object -Property defaultDomainName -EQ $Tenant).customerId
}
else {
} else {
'AllTenants'
}
if ($Request.body.SetAlerts) {
Expand Down Expand Up @@ -58,11 +57,10 @@ $Results = foreach ($Tenant in $tenants) {
EventType = $eventType
ExecutingUser = $Request.headers.'x-ms-client-principal'
}
New-CIPPGraphSubscription @params
Push-OutputBinding -Name Subscription -Value $Params
}
}
}
else {
} else {
foreach ($eventType in $Request.body.EventTypes.value) {
$params = @{
TenantFilter = $tenant
Expand All @@ -78,8 +76,7 @@ $Results = foreach ($Tenant in $tenants) {
}
"Successfully added Alert for $($Tenant) to queue."
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Successfully added Alert for $($Tenant) to queue." -Sev 'Info'
}
catch {
} catch {
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Alert for for $($Tenant) to queue" -Sev 'Error'
"Failed to add Alert for for $($Tenant) to queue $($_.Exception.message)"
}
Expand Down
12 changes: 12 additions & 0 deletions AddAlertSubscription_Queue/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scriptFile": "../Modules/CippEntryPoints/CippEntryPoints.psm1",
"entryPoint": "Receive-CippQueueTrigger",
"bindings": [
{
"name": "QueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "AlertSubscriptions"
}
]
}
75 changes: 37 additions & 38 deletions AddChocoApp/Choco.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{

"displayName": "",
"installCommandLine": "",
"uninstallCommandLine": "",
Expand All @@ -11,47 +10,48 @@
"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" }
"@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"
}
],
"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",
Expand All @@ -60,7 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"


}
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/Immybot.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/automate.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/cwcommand.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/datto.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/huntress.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/syncro.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
36 changes: 18 additions & 18 deletions AddScheduledItems/function.json → AddScheduledItem/function.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
}
30 changes: 30 additions & 0 deletions AddScheduledItem/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$task = $Request.Body
$Table = Get-CIPPTable -TableName 'ScheduledTasks'

$propertiesToCheck = @('Webhook', 'Email', 'PSA')
$PostExecution = ($propertiesToCheck | Where-Object { $task.PostExecution.$_ -eq $true }) -join ','
$Parameters = ($task.Parameters | ConvertTo-Json -Compress)
if ($Parameters -eq 'null') { $Parameters = '' }
$entity = @{
PartitionKey = [string]'ScheduledTask'
TaskState = [string]'Planned'
RowKey = [string]"$(New-Guid)"
Tenant = [string]$task.TenantFilter
Name = [string]$task.Name
Command = [string]$task.Command.value
Parameters = [string]$Parameters
ScheduledTime = [string]$task.ScheduledTime
Recurrence = [string]$task.Recurrence.value
PostExecution = [string]$PostExecution
Results = 'Planned'
}
Write-Host "entity: $($entity | ConvertTo-Json)"
Add-AzDataTableEntity @Table -Entity $entity
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = @{ Results = 'Task added successfully.' }
})
20 changes: 0 additions & 20 deletions AddScheduledItems/run.ps1

This file was deleted.

4 changes: 2 additions & 2 deletions ExecBECRemediate/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$SuspectUser" -tenantid $TenantFilter -type PATCH -body $passwordProfile -verbose
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$SuspectUser" -tenantid $TenantFilter -type PATCH -body '{"accountEnabled":"false"}' -verbose
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$SuspectUser/revokeSignInSessions" -tenantid $TenantFilter -type POST -body '{}' -verbose
$Mailboxes = New-ExoRequest -tenantid $TenantFilter -cmdlet "get-inboxrule" -cmdParams @{Mailbox = $SuspectUser } -anchor $SuspectUser | ForEach-Object {
New-ExoRequest -tenantid $TenantFilter -cmdlet "Disable-InboxRule" -cmdParams @{Confirm = $false; Identity = $_.Identity } -anchor $SuspectUser
$Mailboxes = New-ExoRequest -anchor $SuspectUser -tenantid $TenantFilter -cmdlet "get-inboxrule" -cmdParams @{Mailbox = $SuspectUser } | ForEach-Object {
New-ExoRequest -anchor $SuspectUser -tenantid $TenantFilter -cmdlet "Disable-InboxRule" -cmdParams @{Confirm = $false; Identity = $_.Identity }
}
$results = [pscustomobject]@{"Results" = "Executed Remediation for $SuspectUser and tenant $($TenantFilter). The temporary password is $password and must be changed at next logon." }
Write-LogMessage -API "BECRemediate" -tenant $tenantfilter -message "Executed Remediation for $SuspectUser" -sev "Info"
Expand Down
51 changes: 6 additions & 45 deletions ExecExtensionMapping/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,19 @@ Write-Host 'PowerShell HTTP trigger function processed a request.'
$Table = Get-CIPPTable -TableName CippMapping

if ($Request.Query.List) {
#Get available mappings
$Mappings = [pscustomobject]@{}
Get-AzDataTableEntity @Table | ForEach-Object {
$Mappings | Add-Member -NotePropertyName $_.RowKey -NotePropertyValue @{ label = "$($_.HaloPSAName)"; value = "$($_.HaloPSA)" }
}
#Get Available TEnants
$Tenants = Get-Tenants
#Get available halo clients
$Table = Get-CIPPTable -TableName Extensionsconfig
try {
$Configuration = ((Get-AzDataTableEntity @Table).config | ConvertFrom-Json -ErrorAction Stop).HaloPSA
$Token = Get-HaloToken -configuration $Configuration
$i = 1
$RawHaloClients = do {
$Result = Invoke-RestMethod -Uri "$($Configuration.ResourceURL)/Client?page_no=$i&page_size=999&pageinate=true" -ContentType 'application/json' -Method GET -Headers @{Authorization = "Bearer $($token.access_token)" }
$Result.clients | Select-Object * -ExcludeProperty logo
$i++
$pagecount = [Math]::Ceiling($Result.record_count / 999)
} while ($i -le $pagecount)
} catch { $RawHaloClients = @() }
$HaloClients = $RawHaloClients | ForEach-Object {
[PSCustomObject]@{
label = $_.name
value = $_.id
}
}
$HaloClients = $RawHaloClients | ForEach-Object {
[PSCustomObject]@{
name = $_.name
value = "$($_.id)"
switch ($Request.Query.List) {
'Halo' {
$body = Get-HaloMapping -CIPPMapping $Table
}
}
$MappingObj = [PSCustomObject]@{
Tenants = @($Tenants)
HaloClients = @($HaloClients)
Mappings = $Mappings
}
$body = $MappingObj
}
try {
if ($Request.Query.AddMapping) {
foreach ($Mapping in ([pscustomobject]$Request.body.mappings).psobject.properties) {
$AddObject = @{
PartitionKey = 'Mapping'
RowKey = "$($mapping.name)"
'HaloPSA' = "$($mapping.value.value)"
'HaloPSAName' = "$($mapping.value.label)"
switch ($Request.Query.AddMapping) {
'Halo' {
$body = Set-HaloMapping -CIPPMapping $Table -APIName $APIName -Request $Request
}
Add-AzDataTableEntity @Table -Entity $AddObject -Force
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Added mapping for $($mapping.name)." -Sev 'Info'
}
$body = [pscustomobject]@{'Results' = 'Successfully edited mapping table.' }
}
} catch {
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "mapping API failed. $($_.Exception.Message)" -Sev 'Error'
Expand Down
Loading

0 comments on commit 7420a97

Please sign in to comment.