Skip to content

Commit

Permalink
Merge pull request #3 from KelvinTegelaar/master
Browse files Browse the repository at this point in the history
[pull] master from KelvinTegelaar:master
  • Loading branch information
pull[bot] authored Oct 14, 2023
2 parents ed50c1d + 9f2297c commit f50d148
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/dev_cipppwrro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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 - cipppwrro

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:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cipppwrro'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_9E109464904540339CA94F283ACE1312 }}
3 changes: 2 additions & 1 deletion ExecCPVPermissions/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -

# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
$TenantFilter = (get-tenants | Where-Object -Property customerId -EQ $Request.query.Tenantfilter).defaultDomainName
$TenantFilter = (get-tenants -IncludeAll -IncludeErrors | Where-Object -Property customerId -EQ $Request.query.Tenantfilter).defaultDomainName
Write-Host "Our Tenantfilter is $TenantFilter"
$GraphRequest = try {
Set-CIPPCPVConsent -Tenantfilter $TenantFilter
Add-CIPPApplicationPermission -RequiredResourceAccess "CippDefaults" -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter
Expand Down
2 changes: 1 addition & 1 deletion Modules/CIPPCore/Public/Set-CIPPCPVConsent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function Set-CIPPCPVConsent {
$ExecutingUser
)
$Results = [System.Collections.ArrayList]@()
$Tenant = Get-Tenants | Where-Object -Property defaultDomainName -EQ $Tenantfilter
$Tenant = Get-Tenants -IncludeAll -IncludeErrors | Where-Object -Property defaultDomainName -EQ $Tenantfilter
$TenantName = $Tenant.defaultDomainName
$TenantFilter = $Tenant.customerId

Expand Down
5 changes: 3 additions & 2 deletions Modules/CippExtensions/Private/Get-HaloToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ function Get-HaloToken {
client_secret = (Get-AzKeyVaultSecret -VaultName $ENV:WEBSITE_DEPLOYMENT_ID -Name 'HaloPSA' -AsPlainText)
scope = 'all'
}
if ($Configuration.tenant) { $Tenant = "?tenant=$($Configuration.tenant)"}
if (!([string]::IsNullOrEmpty($Configuration.Tenant))) { $Tenant = "?tenant=$($Configuration.tenant)" }
$token = Invoke-RestMethod -Uri "$($Configuration.AuthURL)/token$Tenant" -Method Post -Body $body -ContentType 'application/x-www-form-urlencoded'
return $token
} else {
}
else {
throw 'No Halo configuration'
}
}
11 changes: 7 additions & 4 deletions Scheduler_CIPPNotifications/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ try {
}
"@
New-GraphPostRequest -uri 'https://graph.microsoft.com/v1.0/me/sendMail' -tenantid $env:TenantID -type POST -body ($JSONBody)
Write-LogMessage -API 'Alerts' -message "Sent alerts to: $($Config.email)" -tenant $Tenant -sev info
}
}
}
Expand Down Expand Up @@ -78,12 +79,13 @@ try {
}
"@
New-GraphPostRequest -uri 'https://graph.microsoft.com/v1.0/me/sendMail' -tenantid $env:TenantID -type POST -body ($JSONBody)
Write-LogMessage -API 'Alerts' -message "Sent alerts to: $($Config.email)" -tenant $Tenant -sev info
}
}
}
catch {
Write-Host "Could not send alerts to email: $($_.Exception.message)"
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -sev info
Write-LogMessage -API 'Alerts' -message "Could not send alerts to: $($_.Exception.message)" -tenant $Tenant -sev error
}


Expand Down Expand Up @@ -119,7 +121,7 @@ try {
Invoke-RestMethod -Uri $config.webhook -Method POST -ContentType 'Application/json' -Body $JSONBody
}
}

Write-LogMessage -API 'Alerts' -tenant $Tenant -message "Sent Webhook to $($config.webhook) " -tenant $Tenant -sev info
}

$UpdateLogs = $CurrentLog | ForEach-Object {
Expand All @@ -132,7 +134,7 @@ try {
}
catch {
Write-Host "Could not send alerts to webhook: $($_.Exception.message)"
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -sev info
Write-LogMessage -API 'Alerts' -message "Could not send alerts to : $($_.Exception.message)" -tenant $Tenant -sev error
}

if ($config.sendtoIntegration) {
Expand All @@ -153,10 +155,11 @@ if ($config.sendtoIntegration) {
Add-AzDataTableEntity @Table -Entity $UpdateLogs -Force
}
}
Write-LogMessage -API 'Alerts' -tenant $Tenant -message "alerts to PSA" -sev info
}
catch {
Write-Host "Could not send alerts to ticketing system: $($_.Exception.message)"
Write-LogMessage -API 'Alerts' -tenant $Tenant -message "Could not send alerts to : $($_.Exception.message)" -sev info
Write-LogMessage -API 'Alerts' -tenant $Tenant -message "Could not send alerts to ticketing system: $($_.Exception.message)" -sev Error
}
}

Expand Down
2 changes: 1 addition & 1 deletion UpdatePermissions/run.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Input bindings are passed in via param block.
param($Timer)

$Tenants = get-tenants
$Tenants = get-tenants -IncludeAll
foreach ($Row in $Tenants) {
Push-OutputBinding -Name Msg -Value $row
}
2 changes: 1 addition & 1 deletion version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.0
4.4.2

0 comments on commit f50d148

Please sign in to comment.