Skip to content

Commit 9a69a53

Browse files
authored
Merge pull request #119 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 33b082b + 1c9bc22 commit 9a69a53

File tree

16 files changed

+171
-82
lines changed

16 files changed

+171
-82
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphBulkRequest.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ function Invoke-ListGraphBulkRequest {
1515
$TenantFilter = $Request.Body.tenantFilter
1616
$AsApp = $Request.Body.asApp
1717
$Requests = $Request.Body.requests
18+
$NoPaginateIds = $Request.Body.noPaginateIds
1819

1920
$GraphRequestParams = @{
2021
tenantid = $TenantFilter
2122
Requests = @()
23+
NoPaginateIds = $NoPaginateIds ?? @()
2224
}
2325

2426
if ($AsApp) {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Administration/Invoke-ExecHideFromGAL.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Function Invoke-ExecHideFromGAL {
1010
[CmdletBinding()]
1111
param($Request, $TriggerMetadata)
1212

13-
$Headers = $Request.Headers
1413
$APIName = $Request.Params.CIPPEndpoint
14+
$Headers = $Request.Headers
1515
Write-LogMessage -Headers $Headers -API $APINAME -message 'Accessed this API' -Sev 'Debug'
1616

1717

@@ -22,19 +22,17 @@ Function Invoke-ExecHideFromGAL {
2222
$HideFromGAL = [System.Convert]::ToBoolean($HideFromGAL)
2323

2424
Try {
25-
$HideResults = Set-CIPPHideFromGAL -tenantFilter $TenantFilter -UserID $UserId -hidefromgal $Hidden -Headers $Request.Headers -APIName $APIName
26-
$Results = [pscustomobject]@{'Results' = $HideResults }
25+
$Result = Set-CIPPHideFromGAL -tenantFilter $TenantFilter -UserID $UserId -hidefromgal $HideFromGAL -Headers $Headers -APIName $APIName
2726
$StatusCode = [HttpStatusCode]::OK
2827

2928
} catch {
30-
$ErrorMessage = Get-CippException -Exception $_
31-
$Results = [pscustomobject]@{'Results' = "Failed. $($ErrorMessage.NormalizedError)" }
29+
$Result = $_.Exception.Message
3230
$StatusCode = [HttpStatusCode]::Forbidden
3331
}
3432
# Associate values to output bindings by calling 'Push-OutputBinding'.
3533
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
3634
StatusCode = $StatusCode
37-
Body = $Results
35+
Body = @{ 'Results' = $Result }
3836
})
3937

4038
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Administration/Invoke-ExecStartManagedFolderAssistant.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Function Invoke-ExecStartManagedFolderAssistant {
2424

2525
$ExoParams = @{
2626
Identity = $Identity
27-
AggMailboxCleanup = $true
2827
FullCrawl = $true
2928
}
3029

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Administration/Invoke-ListMailboxes.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ Function Invoke-ListMailboxes {
1111
param($Request, $TriggerMetadata)
1212

1313
$APIName = $Request.Params.CIPPEndpoint
14-
Write-LogMessage -headers $Request.Headers -API $APINAME -message 'Accessed this API' -Sev 'Debug'
14+
$Headers = $Request.Headers
15+
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
1516

1617
# Interact with query parameters or the body of the request.
17-
$TenantFilter = $Request.Query.TenantFilter
18+
$TenantFilter = $Request.Query.tenantFilter
1819
try {
1920
$Select = 'id,ExchangeGuid,ArchiveGuid,UserPrincipalName,DisplayName,PrimarySMTPAddress,RecipientType,RecipientTypeDetails,EmailAddresses,WhenSoftDeleted,IsInactiveMailbox,ForwardingSmtpAddress,DeliverToMailboxAndForward,ForwardingAddress,HiddenFromAddressListsEnabled,ExternalDirectoryObjectId,MessageCopyForSendOnBehalfEnabled,MessageCopyForSentAsEnabled'
2021
$ExoRequest = @{
@@ -32,6 +33,7 @@ Function Invoke-ListMailboxes {
3233
@{Parameter = 'PublicFolder'; Type = 'Bool' }
3334
@{Parameter = 'RecipientTypeDetails'; Type = 'String' }
3435
@{Parameter = 'SoftDeletedMailbox'; Type = 'Bool' }
36+
@{Parameter = 'Identity'; Type = 'String' }
3537
)
3638

3739
foreach ($Param in $Request.Query.PSObject.Properties.Name) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ Function Invoke-ListIntunePolicy {
4343
method = 'GET'
4444
url = "/deviceManagement/windowsFeatureUpdateProfiles?`$expand=assignments&top=200"
4545
}
46+
@{
47+
id = 'windowsQualityUpdatePolicies'
48+
method = 'GET'
49+
url = "/deviceManagement/windowsQualityUpdatePolicies?`$expand=assignments&top=200"
50+
}
51+
@{
52+
id = 'windowsQualityUpdateProfiles'
53+
method = 'GET'
54+
url = "/deviceManagement/windowsQualityUpdateProfiles?`$expand=assignments&top=200"
55+
}
4656
@{
4757
id = 'GroupPolicyConfigurations'
4858
method = 'GET'
@@ -78,6 +88,11 @@ Function Invoke-ListIntunePolicy {
7888
'*microsoft.graph.macOSEndpointProtectionConfiguration*' { 'MacOS Endpoint Protection' }
7989
'*microsoft.graph.androidWorkProfileGeneralDeviceConfiguration*' { 'Android Configuration' }
8090
'*windowsFeatureUpdateProfiles*' { 'Feature Update' }
91+
'*windowsQualityUpdatePolicies*' { 'Quality Update' }
92+
'*windowsQualityUpdateProfiles*' { 'Quality Update' }
93+
'*iosUpdateConfiguration*' { 'iOS Update Configuration' }
94+
'*windowsDriverUpdateProfiles*' { 'Driver Update' }
95+
'*configurationPolicies*' { 'Device Configuration' }
8196
default { $_.'[email protected]' }
8297
}
8398
$Assignments = $_.assignments.target | Select-Object -Property '@odata.type', groupId
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
function Invoke-ExecDismissRiskyUser {
2-
<#
3-
.FUNCTIONALITY
4-
Entrypoint
5-
.ROLE
6-
Identity.User.ReadWrite
7-
#>
8-
[CmdletBinding()]
9-
param($Request, $TriggerMetadata)
10-
11-
$APIName = $Request.Params.CIPPEndpoint
12-
$Headers = $Request.Headers
13-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
14-
15-
# Interact with the query or body of the request
16-
$TenantFilter = $Request.Query.tenantFilter ?? $Request.Body.tenantFilter
17-
$SuspectUser = $Request.Query.userId ?? $Request.Body.userId
18-
$userDisplayName = $Request.Query.userDisplayName ?? $Request.Body.userDisplayName
19-
20-
$GraphRequest = @{
21-
'uri' = 'https://graph.microsoft.com/beta/riskyUsers/dismiss'
22-
'tenantid' = $TenantFilter
23-
'type' = 'POST'
24-
'contentType' = 'application/json; charset=utf-8'
25-
'body' = @{
26-
'userIds' = @($SuspectUser)
27-
} | ConvertTo-Json
28-
}
29-
30-
try {
31-
$GraphResults = New-GraphPostRequest @GraphRequest
32-
Write-LogMessage -API $APIName -tenant $TenantFilter -message "Dismissed user risk for $userDisplayName" -sev 'Info'
33-
$Result = "Successfully dismissed User Risk for user $userDisplayName. $GraphResults"
34-
$StatusCode = [HttpStatusCode]::OK
35-
} catch {
36-
$ErrorMessage = Get-CippException -Exception $_
37-
$Result = "Failed to dismiss user risk for $userDisplayName. $($ErrorMessage.NormalizedError)"
38-
Write-LogMessage -API $APIName -tenant $TenantFilter -message $Result -sev 'Error' -LogData $ErrorMessage
39-
$StatusCode = [HttpStatusCode]::InternalServerError
40-
}
41-
42-
# Associate values to output bindings by calling 'Push-OutputBinding'.
43-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
44-
StatusCode = $StatusCode
45-
Body = @{ 'Results' = $Result }
46-
})
47-
}
1+
function Invoke-ExecDismissRiskyUser {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
.ROLE
6+
Identity.User.ReadWrite
7+
#>
8+
[CmdletBinding()]
9+
param($Request, $TriggerMetadata)
10+
11+
$APIName = $Request.Params.CIPPEndpoint
12+
$Headers = $Request.Headers
13+
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
14+
15+
# Interact with the query or body of the request
16+
$TenantFilter = $Request.Query.tenantFilter ?? $Request.Body.tenantFilter
17+
$SuspectUser = $Request.Query.userId ?? $Request.Body.userId
18+
$userDisplayName = $Request.Query.userDisplayName ?? $Request.Body.userDisplayName
19+
20+
$GraphRequest = @{
21+
'uri' = 'https://graph.microsoft.com/beta/riskyUsers/dismiss'
22+
'tenantid' = $TenantFilter
23+
'type' = 'POST'
24+
'contentType' = 'application/json; charset=utf-8'
25+
'body' = @{
26+
'userIds' = @($SuspectUser)
27+
} | ConvertTo-Json
28+
}
29+
30+
try {
31+
$GraphResults = New-GraphPostRequest @GraphRequest
32+
Write-LogMessage -API $APIName -tenant $TenantFilter -message "Dismissed user risk for $userDisplayName" -sev 'Info'
33+
$Result = "Successfully dismissed User Risk for user $userDisplayName. $GraphResults"
34+
$StatusCode = [HttpStatusCode]::OK
35+
} catch {
36+
$ErrorMessage = Get-CippException -Exception $_
37+
$Result = "Failed to dismiss user risk for $userDisplayName. $($ErrorMessage.NormalizedError)"
38+
Write-LogMessage -API $APIName -tenant $TenantFilter -message $Result -sev 'Error' -LogData $ErrorMessage
39+
$StatusCode = [HttpStatusCode]::InternalServerError
40+
}
41+
42+
# Associate values to output bindings by calling 'Push-OutputBinding'.
43+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
44+
StatusCode = $StatusCode
45+
Body = @{ 'Results' = $Result }
46+
})
47+
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,20 @@ Function Invoke-ListUserMailboxDetails {
183183
AutoExpandingArchive = $AutoExpandingArchiveEnabled
184184
RecipientTypeDetails = $MailboxDetailedRequest.RecipientTypeDetails
185185
Mailbox = $MailboxDetailedRequest
186-
}
186+
MailboxActionsData = ($MailboxDetailedRequest | Select-Object id, ExchangeGuid, ArchiveGuid, WhenSoftDeleted, @{ Name = 'UPN'; Expression = { $_.'UserPrincipalName' } },
187+
@{ Name = 'displayName'; Expression = { $_.'DisplayName' } },
188+
@{ Name = 'primarySmtpAddress'; Expression = { $_.'PrimarySMTPAddress' } },
189+
@{ Name = 'recipientType'; Expression = { $_.'RecipientType' } },
190+
@{ Name = 'recipientTypeDetails'; Expression = { $_.'RecipientTypeDetails' } },
191+
@{ Name = 'AdditionalEmailAddresses'; Expression = { ($_.'EmailAddresses' | Where-Object { $_ -clike 'smtp:*' }).Replace('smtp:', '') -join ', ' } },
192+
@{Name = 'ForwardingSmtpAddress'; Expression = { $_.'ForwardingSmtpAddress' -replace 'smtp:', '' } },
193+
@{Name = 'InternalForwardingAddress'; Expression = { $_.'ForwardingAddress' } },
194+
DeliverToMailboxAndForward,
195+
HiddenFromAddressListsEnabled,
196+
ExternalDirectoryObjectId,
197+
MessageCopyForSendOnBehalfEnabled,
198+
MessageCopyForSentAsEnabled)
199+
} # Select statement taken from ListMailboxes to save a EXO request
187200

188201
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
189202
StatusCode = [HttpStatusCode]::OK

Modules/CIPPCore/Public/GraphHelper/New-GraphBulkRequest.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function New-GraphBulkRequest {
88
$NoAuthCheck,
99
$scope,
1010
$asapp,
11-
$Requests
11+
$Requests,
12+
$NoPaginateIds = @()
1213
)
1314

1415
if ($NoAuthCheck -or (Get-AuthorisedRequest -Uri $uri -TenantID $tenantid)) {
@@ -43,6 +44,9 @@ function New-GraphBulkRequest {
4344
$Return
4445
}
4546
foreach ($MoreData in $ReturnedData.Responses | Where-Object { $_.body.'@odata.nextLink' }) {
47+
if ($NoPaginateIds -contains $MoreData.id) {
48+
continue
49+
}
4650
Write-Host 'Getting more'
4751
Write-Host $MoreData.body.'@odata.nextLink'
4852
$AdditionalValues = New-GraphGetRequest -ComplexFilter -uri $MoreData.body.'@odata.nextLink' -tenantid $tenantid -NoAuthCheck $NoAuthCheck -scope $scope -AsApp $asapp

Modules/CIPPCore/Public/New-CIPPBackupTask.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ function New-CIPPBackupTask {
4141
"https://graph.microsoft.com/beta/deviceAppManagement/mobileAppConfigurations?`$expand=assignments&`$filter=microsoft.graph.androidManagedStoreAppConfiguration/appSupportsOemConfig%20eq%20true"
4242
'https://graph.microsoft.com/beta/deviceManagement/configurationPolicies'
4343
'https://graph.microsoft.com/beta/deviceManagement/windowsFeatureUpdateProfiles'
44+
'https://graph.microsoft.com/beta/deviceManagement/windowsQualityUpdatePolicies'
45+
'https://graph.microsoft.com/beta/deviceManagement/windowsQualityUpdateProfiles'
4446
)
4547

4648
$Policies = foreach ($url in $GraphURLS) {

Modules/CIPPCore/Public/New-CIPPIntuneTemplate.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ function New-CIPPIntuneTemplate {
103103
$DisplayName = $Template.displayName
104104
$TemplateJson = ConvertTo-Json -InputObject $Template -Depth 100 -Compress
105105
}
106+
'windowsQualityUpdatePolicies' {
107+
$Type = 'windowsQualityUpdatePolicies'
108+
$Template = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$($urlname)/$($ID)" -tenantid $tenantfilter | Select-Object * -ExcludeProperty id, lastModifiedDateTime, '@odata.context', 'ScopeTagIds', 'supportsScopeTags', 'createdDateTime'
109+
$DisplayName = $Template.displayName
110+
$TemplateJson = ConvertTo-Json -InputObject $Template -Depth 100 -Compress
111+
}
112+
'windowsQualityUpdateProfiles' {
113+
$Type = 'windowsQualityUpdateProfiles'
114+
$Template = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$($urlname)/$($ID)" -tenantid $tenantfilter | Select-Object * -ExcludeProperty id, lastModifiedDateTime, '@odata.context', 'ScopeTagIds', 'supportsScopeTags', 'createdDateTime'
115+
$DisplayName = $Template.displayName
116+
$TemplateJson = ConvertTo-Json -InputObject $Template -Depth 100 -Compress
117+
}
106118
}
107119
return [PSCustomObject]@{
108120
TemplateJson = $TemplateJson

0 commit comments

Comments
 (0)