Skip to content

Commit 12d3956

Browse files
authored
Merge pull request #758 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents dce60cf + a35798a commit 12d3956

File tree

7 files changed

+77
-8
lines changed

7 files changed

+77
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Get-CIPPAlertLowDomainScore {
1313
)
1414

1515
$DomainData = Get-CIPPDomainAnalyser -TenantFilter $TenantFilter
16-
$LowScoreDomains = $DomainData | Where-Object { $_.ScorePercentage -lt $InputValue -and $_.ScorePercentage -ne '' } | ForEach-Object {
16+
$LowScoreDomains = $DomainData | Where-Object { $_.ScorePercentage -lt $InputValue -and $_.ScorePercentage -ne '' -and $_.Domain -notlike '*.onmicrosoft.com' -and $_.Domain -notlike '*.mail.onmicrosoft.com' } | ForEach-Object {
1717
[PSCustomObject]@{
1818
Message = "$($_.Domain): Domain security score is $($_.ScorePercentage)%, which is below the threshold of $InputValue%. Issues: $($_.ScoreExplanation)"
1919
Domain = $_.Domain

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-ExecSyncVPP.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ function Invoke-ExecSyncVPP {
99
param($Request, $TriggerMetadata)
1010
$APIName = $Request.Params.CIPPEndpoint
1111
$Headers = $Request.Headers
12-
Write-LogMessage -Headers $Headers -API $APIName -message 'Accessed this API' -Sev Debug
1312

14-
$TenantFilter = $Request.Body.tenantFilter ?? $Request.Query.tenantFilter
13+
$TenantFilter = $Request.Body.tenantFilter
1514
try {
1615
# Get all VPP tokens and sync them
1716
$VppTokens = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceAppManagement/vppTokens' -tenantid $TenantFilter | Where-Object { $_.state -eq 'valid' }

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-AddPolicy.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ function Invoke-AddPolicy {
1717
$description = $Request.Body.Description
1818
$AssignTo = if ($Request.Body.AssignTo -ne 'on') { $Request.Body.AssignTo }
1919
$ExcludeGroup = $Request.Body.excludeGroup
20+
$AssignmentFilterSelection = $Request.Body.AssignmentFilterName ?? $Request.Body.assignmentFilter
21+
$AssignmentFilterType = $Request.Body.AssignmentFilterType ?? $Request.Body.assignmentFilterType
22+
$AssignmentFilterName = switch ($AssignmentFilterSelection) {
23+
{ $_ -is [string] } { $_; break }
24+
{ $_ -and $_.PSObject.Properties['value'] } { $_.value; break }
25+
{ $_ -and $_.PSObject.Properties['displayName'] } { $_.displayName; break }
26+
{ $_ -and $_.PSObject.Properties['label'] } { $_.label; break }
27+
default { $null }
28+
}
2029
$Request.Body.customGroup ? ($AssignTo = $Request.Body.customGroup) : $null
2130
$RawJSON = $Request.Body.RAWJson
2231

@@ -70,6 +79,12 @@ function Invoke-AddPolicy {
7079
Headers = $Headers
7180
APIName = $APIName
7281
}
82+
83+
if (-not [string]::IsNullOrWhiteSpace($AssignmentFilterName)) {
84+
$params.AssignmentFilterName = $AssignmentFilterName
85+
$params.AssignmentFilterType = [string]::IsNullOrWhiteSpace($AssignmentFilterType) ? 'include' : $AssignmentFilterType
86+
}
87+
7388
Set-CIPPIntunePolicy @params
7489
} catch {
7590
"$($_.Exception.Message)"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
function Invoke-ExecSyncDEP {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
.ROLE
6+
Endpoint.MEM.ReadWrite
7+
.DESCRIPTION
8+
Syncs devices from Apple Business Manager to Intune
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
$APIName = $Request.Params.CIPPEndpoint
13+
$Headers = $Request.Headers
14+
15+
$TenantFilter = $Request.Body.tenantFilter
16+
try {
17+
$DepOnboardingSettings = @(New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/depOnboardingSettings' -tenantid $TenantFilter)
18+
19+
if ($null -eq $DepOnboardingSettings -or $DepOnboardingSettings.Count -eq 0) {
20+
$Result = 'No Apple Business Manager connections found'
21+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev Info
22+
} else {
23+
$SyncCount = 0
24+
foreach ($DepSetting in $DepOnboardingSettings) {
25+
if ($DepSetting.id) {
26+
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/depOnboardingSettings/$($DepSetting.id)/syncWithAppleDeviceEnrollmentProgram" -tenantid $TenantFilter
27+
$SyncCount++
28+
}
29+
}
30+
if ($SyncCount -eq 0) {
31+
$Result = 'No Apple Business Manager connections found'
32+
} else {
33+
$Result = "Successfully started device sync for $SyncCount Apple Business Manager connection$(if ($SyncCount -gt 1) { 's' })"
34+
}
35+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev Info
36+
}
37+
$StatusCode = [HttpStatusCode]::OK
38+
} catch {
39+
$ErrorMessage = Get-CippException -Exception $_
40+
$Result = 'Failed to start Apple Business Manager device sync'
41+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev Error -LogData $ErrorMessage
42+
$StatusCode = [HttpStatusCode]::Forbidden
43+
}
44+
45+
return ([HttpResponseContext]@{
46+
StatusCode = $StatusCode
47+
Body = @{ Results = $Result }
48+
})
49+
50+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-AddUser.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ function Invoke-AddUser {
7575
'User' = $CreationResults.User
7676
}
7777
} catch {
78+
$ErrorMessage = $_.TargetObject.Results -join ' '
79+
$ErrorMessage = [string]::IsNullOrWhiteSpace($ErrorMessage) ? $_.Exception.Message : $ErrorMessage
7880
$body = [pscustomobject] @{
79-
'Results' = @("$($_.Exception.Message)")
81+
'Results' = @("$ErrorMessage")
8082
}
8183
$StatusCode = [HttpStatusCode]::InternalServerError
8284
}

Modules/CIPPCore/Public/New-CIPPBackup.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ function New-CIPPBackup {
5454
'WebhookRules'
5555
'ScheduledTasks'
5656
'TenantProperties'
57+
'TenantGroups'
58+
'TenantGroupMembers'
5759
)
5860
$CSVfile = foreach ($CSVTable in $BackupTables) {
5961
$Table = Get-CippTable -tablename $CSVTable

Modules/CIPPCore/Public/New-CIPPCAPolicy.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,19 @@ function New-CIPPCAPolicy {
195195
}
196196
} else {
197197
if ($location.countriesAndRegions) { $location.countriesAndRegions = @($location.countriesAndRegions) }
198-
$location | Select-Object * -ExcludeProperty id
199-
Remove-ODataProperties -Object $location
200-
$Body = ConvertTo-Json -InputObject $Location
198+
$LocationBody = $location | Select-Object * -ExcludeProperty id
199+
Remove-ODataProperties -Object $LocationBody
200+
$Body = ConvertTo-Json -InputObject $LocationBody
201201
$GraphRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations' -body $body -Type POST -tenantid $tenantfilter -asApp $true
202202
$retryCount = 0
203+
$MaxRetryCount = 10
203204
do {
204205
Write-Host "Checking for location $($GraphRequest.id) attempt $retryCount. $TenantFilter"
205206
$LocationRequest = New-GraphGETRequest -uri 'https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations' -tenantid $tenantfilter -asApp $true | Where-Object -Property id -EQ $GraphRequest.id
206207
Write-Host "LocationRequest: $($LocationRequest.id)"
207208
Start-Sleep -Seconds 2
208209
$retryCount++
209-
} while ((!$LocationRequest -or !$LocationRequest.id) -and ($retryCount -lt 5))
210+
} while ((!$LocationRequest -or !$LocationRequest.id) -and ($retryCount -lt $MaxRetryCount))
210211
Write-LogMessage -Tenant $TenantFilter -Headers $Headers -API $APINAME -message "Created new Named Location: $($location.displayName)" -Sev 'Info'
211212
[pscustomobject]@{
212213
id = $GraphRequest.id

0 commit comments

Comments
 (0)