Skip to content

Commit 80edcde

Browse files
authored
Merge pull request KelvinTegelaar#270 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents b49ad60 + 62044da commit 80edcde

19 files changed

+802
-237
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy Powershell project to Azure Function App - cippbcaom
5+
6+
on:
7+
push:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
12+
env:
13+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
14+
15+
jobs:
16+
deploy:
17+
runs-on: windows-latest
18+
19+
steps:
20+
- name: 'Checkout GitHub Action'
21+
uses: actions/checkout@v4
22+
23+
- name: 'Run Azure Functions Action'
24+
uses: Azure/functions-action@v1
25+
id: fa
26+
with:
27+
app-name: 'cippbcaom'
28+
slot-name: 'Production'
29+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
30+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_56AD4FDD49354D0CAB4D9A9E868D2015 }}

ConversionTable.csv

Lines changed: 153 additions & 34 deletions
Large diffs are not rendered by default.

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertMFAAdmins.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Get-CIPPAlertMFAAdmins {
1818
}
1919
}
2020
if (!$DuoActive) {
21-
$users = New-GraphGETRequest -uri 'https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?$top=999&$filter=IsAdmin eq true and userDisplayName ne ''On-Premises Directory Synchronization Service Account''' -tenantid $($TenantFilter) | Where-Object -Property 'isMfaRegistered' -EQ $false
21+
$users = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?`$top=999&filter=IsAdmin eq true and isMfaRegistered eq false and userType eq 'member'&`$select=userPrincipalName,lastUpdatedDateTime,isMfaRegistered,IsAdmin" -tenantid $($TenantFilter) | Where-Object { $_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' }
2222
if ($users.UserPrincipalName) {
2323
$AlertData = "The following admins do not have MFA registered: $($users.UserPrincipalName -join ', ')"
2424
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertMFAAlertUsers.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Get-CIPPAlertMFAAlertUsers {
1212
)
1313
try {
1414

15-
$users = New-GraphGETRequest -uri 'https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?$top=999&filter=isMfaRegistered eq false and userType eq ''member'' and userDisplayName ne ''On-Premises Directory Synchronization Service Account''&$select=userPrincipalName,lastUpdatedDateTime,isMfaRegistered' -tenantid $($TenantFilter)
15+
$users = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?`$top=999&filter=IsAdmin eq false and isMfaRegistered eq false and userType eq 'member'&`$select=userPrincipalName,lastUpdatedDateTime,isMfaRegistered,IsAdmin" -tenantid $($TenantFilter) | Where-Object { $_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' }
1616
if ($users.UserPrincipalName) {
1717
$AlertData = "The following $($users.Count) users do not have MFA registered: $($users.UserPrincipalName -join ', ')"
1818
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData

Modules/CIPPCore/Public/ConversionTable.csv

Lines changed: 153 additions & 34 deletions
Large diffs are not rendered by default.

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-UpdateTenants.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ function Push-UpdateTenants {
66
Param($Item)
77
$QueueReference = 'UpdateTenants'
88
$RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -ne 'Completed' -and $_.Status -ne 'Failed' }
9-
if ($RunningQueue) {
10-
Write-Host 'Update Tenants already running'
11-
return
12-
}
9+
1310
$Queue = New-CippQueueEntry -Name 'Update Tenants' -Reference $QueueReference -TotalTasks 1
1411
try {
1512
$QueueTask = @{
@@ -30,4 +27,4 @@ function Push-UpdateTenants {
3027
$QueueTask.Status = 'Failed'
3128
Set-CippQueueTask @QueueTask
3229
}
33-
}
30+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Autopilot/Invoke-ExecAssignAPDevice.ps1

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,35 @@ Function Invoke-ExecAssignAPDevice {
1010
[CmdletBinding()]
1111
param($Request, $TriggerMetadata)
1212
$APIName = $TriggerMetadata.FunctionName
13-
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
14-
$tenantfilter = $Request.Body.TenantFilter
13+
$User = $request.headers.'x-ms-client-principal'
14+
Write-LogMessage -user $User -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15+
$TenantFilter = $Request.body.tenantFilter
16+
17+
1518
try {
19+
$UserObject = $Request.body.user.addedFields
20+
$DeviceObject = $Request.body.device
21+
$SerialNumber = $Request.body.serialNumber
1622
$body = @{
17-
UserPrincipalName = $Request.body.UserPrincipalName
18-
addressableUserName = $Request.body.addressableUserName
23+
userPrincipalName = $UserObject.userPrincipalName
24+
addressableUserName = $UserObject.addressableUserName
1925
} | ConvertTo-Json
20-
New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeviceIdentities/$($request.body.Device)/UpdateDeviceProperties" -tenantid $TenantFilter -body $body -method POST
21-
$Results = "Successfully assigned device to $($Request.body.UserPrincipalName) for $($tenantfilter)"
26+
New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeviceIdentities/$($DeviceObject)/UpdateDeviceProperties" -tenantid $TenantFilter -body $body -method POST | Out-Null
27+
Write-LogMessage -user $User -API $APINAME -message "Successfully assigned device: $DeviceObject with Serial: $SerialNumber to $($UserObject.userPrincipalName) for $($TenantFilter)" -Sev Info
28+
$Results = "Successfully assigned device: $DeviceObject with Serial: $SerialNumber to $($UserObject.userPrincipalName) for $($TenantFilter)"
29+
$StatusCode = [HttpStatusCode]::OK
2230
} catch {
23-
$Results = "Could not $($Request.body.UserPrincipalName) to $($Request.body.device) for $($tenantfilter) Error: $($_.Exception.Message)"
31+
$ErrorMessage = Get-CippException -Exception $_
32+
Write-LogMessage -user $User -API $APINAME -message "Could not assign $($UserObject.userPrincipalName) to $($DeviceObject) for $($TenantFilter) Error: $($ErrorMessage.NormalizedError)" -Sev Error -LogData $ErrorMessage
33+
$Results = "Could not assign $($UserObject.userPrincipalName) to $($DeviceObject) for $($TenantFilter) Error: $($ErrorMessage.NormalizedError)"
34+
$StatusCode = [HttpStatusCode]::BadRequest
2435
}
2536

2637
$Results = [pscustomobject]@{'Results' = "$results" }
2738

2839
# Associate values to output bindings by calling 'Push-OutputBinding'.
2940
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
30-
StatusCode = [HttpStatusCode]::OK
41+
StatusCode = $StatusCode
3142
Body = $Results
3243
})
3344

0 commit comments

Comments
 (0)