Skip to content

Commit 6532ffc

Browse files
authored
Merge pull request #493 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 5dcd211 + dc2a278 commit 6532ffc

File tree

67 files changed

+36
-271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+36
-271
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ function Invoke-ListGraphRequest {
124124

125125
try {
126126
$Results = Get-GraphRequestList @GraphRequestParams
127+
128+
if ($script:LastGraphResponseHeaders) {
129+
$Metadata.GraphHeaders = $script:LastGraphResponseHeaders
130+
}
131+
127132
if ($Results | Where-Object { $_.PSObject.Properties.Name -contains 'nextLink' }) {
128133
if (![string]::IsNullOrEmpty($Results.nextLink) -and $Request.Query.TenantFilter -ne 'AllTenants') {
129134
Write-Host "NextLink: $($Results.nextLink | Where-Object { $_ } | Select-Object -Last 1)"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Transport/Invoke-AddTransportRule.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function Invoke-AddTransportRule {
1414

1515
$RequestParams = $Request.Body.PowerShellCommand | ConvertFrom-Json | Select-Object -Property * -ExcludeProperty GUID, HasSenderOverride, ExceptIfHasSenderOverride, ExceptIfMessageContainsDataClassifications, MessageContainsDataClassifications
1616

17+
# Remove null properties from payload
18+
$RequestParams.PSObject.Properties | Where-Object { $_.Value -eq $null } | ForEach-Object { $RequestParams.PSObject.Properties.Remove($_.Name) }
19+
1720
$Tenants = ($Request.body.selectedTenants).value
1821

1922
$AllowedTenants = Test-CippAccess -Request $Request -TenantList

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/New-CippCoreRequest.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ function New-CippCoreRequest {
2121
}
2222

2323
if ($PSCmdlet.ShouldProcess("Processing request for $($Request.Params.CIPPEndpoint)")) {
24+
# Set script scope variables for Graph API to indicate HTTP request/high priority
25+
$script:XMsThrottlePriority = 'high'
26+
2427
if ((Get-Command -Name $FunctionName -ErrorAction SilentlyContinue) -or $FunctionName -eq 'Invoke-Me') {
2528
try {
2629
$Access = Test-CIPPAccess -Request $Request

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Tenant/Invoke-ListTenants.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,16 @@ function Invoke-ListTenants {
7070
}
7171
try {
7272
$TenantFilter = $Request.Query.tenantFilter
73-
$Tenants = Get-Tenants -IncludeErrors -SkipDomains
73+
$tenantParams = @{
74+
IncludeErrors = $true
75+
SkipDomains = $true
76+
}
77+
if ($TenantFilter -and $TenantFilter -ne 'AllTenants') {
78+
$tenantParams['TenantFilter'] = $TenantFilter
79+
}
80+
81+
$Tenants = Get-Tenants @tenantParams
82+
7483
if ($TenantAccess -notcontains 'AllTenants') {
7584
$Tenants = $Tenants | Where-Object -Property customerId -In $TenantAccess
7685
}
@@ -98,7 +107,7 @@ function Invoke-ListTenants {
98107
}
99108
}
100109

101-
if ($null -eq $TenantFilter -or $TenantFilter -eq 'null') {
110+
if (($null -eq $TenantFilter -or $TenantFilter -eq 'null') -or $Request.Query.Mode -eq 'TenantList') {
102111
$TenantList = [system.collections.generic.list[object]]::new()
103112
if ($AllTenantSelector -eq $true) {
104113
$AllTenantsObject = @{
@@ -141,7 +150,7 @@ function Invoke-ListTenants {
141150
}
142151

143152
} else {
144-
$body = $Tenants | Where-Object -Property defaultDomainName -EQ $TenantFilter
153+
$body = $Tenants
145154
}
146155

147156
Write-LogMessage -headers $Headers -tenant $TenantFilter -API $APIName -message 'Listed Tenant Details' -Sev 'Debug'

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ function New-GraphBulkRequest {
1717
if ($NoAuthCheck -or (Get-AuthorisedRequest -Uri $uri -TenantID $tenantid)) {
1818
$headers = Get-GraphToken -tenantid $tenantid -scope $scope -AsApp $asapp
1919

20+
if ($script:XMsThrottlePriority) {
21+
$headers['x-ms-throttle-priority'] = $script:XMsThrottlePriority
22+
}
23+
2024
$URL = "https://graph.microsoft.com/$Version/`$batch"
2125

2226
# Track consecutive Graph API failures

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function New-GraphGetRequest {
3636
if ($ComplexFilter) {
3737
$headers['ConsistencyLevel'] = 'eventual'
3838
}
39+
40+
if ($script:XMsThrottlePriority) {
41+
$headers['x-ms-throttle-priority'] = $script:XMsThrottlePriority
42+
}
43+
3944
$nextURL = $uri
4045
if ($extraHeaders) {
4146
foreach ($key in $extraHeaders.Keys) {
@@ -68,15 +73,14 @@ function New-GraphGetRequest {
6873
Headers = $headers
6974
ContentType = 'application/json; charset=utf-8'
7075
}
71-
if ($IncludeResponseHeaders) {
72-
$GraphRequest.ResponseHeadersVariable = 'ResponseHeaders'
73-
}
7476

7577
if ($ReturnRawResponse) {
7678
$GraphRequest.SkipHttpErrorCheck = $true
7779
$Data = Invoke-WebRequest @GraphRequest
7880
} else {
81+
$GraphRequest.ResponseHeadersVariable = 'ResponseHeaders'
7982
$Data = (Invoke-RestMethod @GraphRequest)
83+
$script:LastGraphResponseHeaders = $ResponseHeaders
8084
}
8185

8286
# If we reach here, the request was successful

Modules/MicrosoftTeams/7.3.1/net472/CmdletSettings.json

Lines changed: 0 additions & 255 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)