Skip to content

Commit 663a190

Browse files
add extra headers to sharepoint
1 parent 1c4d8dc commit 663a190

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Teams-Sharepoint/Invoke-ListSharepointQuota.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ Function Invoke-ListSharepointQuota {
2222
} else {
2323
try {
2424
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
25-
$SharePointQuota = (New-GraphGetRequest -scope "$($SharePointInfo.AdminUrl)/.default" -tenantid $TenantFilter -uri "$($SharePointInfo.AdminUrl)/_api/StorageQuotas()?api-version=1.3.2").value | Sort-Object -Property GeoUsedStorageMB -Descending | Select-Object -First 1
25+
$extraHeaders = @{
26+
'Accept' = 'application/json'
27+
}
28+
$SharePointQuota = (New-GraphGetRequest -extraHeaders $extraHeaders -scope "$($SharePointInfo.AdminUrl)/.default" -tenantid $TenantFilter -uri "$($SharePointInfo.AdminUrl)/_api/StorageQuotas()?api-version=1.3.2") | Sort-Object -Property GeoUsedStorageMB -Descending | Select-Object -First 1
2629

2730
if ($SharePointQuota) {
2831
$UsedStoragePercentage = [int](($SharePointQuota.GeoUsedStorageMB / $SharePointQuota.TenantStorageMB) * 100)

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ function New-GraphGetRequest {
1515
$Caller,
1616
[switch]$ComplexFilter,
1717
[switch]$CountOnly,
18-
[switch]$IncludeResponseHeaders
18+
[switch]$IncludeResponseHeaders,
19+
[hashtable]$extraHeaders
1920
)
2021

2122
if ($NoAuthCheck -eq $false) {
@@ -35,7 +36,11 @@ function New-GraphGetRequest {
3536
$headers['ConsistencyLevel'] = 'eventual'
3637
}
3738
$nextURL = $uri
38-
39+
if ($extraHeaders) {
40+
foreach ($key in $extraHeaders.Keys) {
41+
$headers[$key] = $extraHeaders[$key]
42+
}
43+
}
3944
# Track consecutive Graph API failures
4045
$TenantsTable = Get-CippTable -tablename Tenants
4146
$Filter = "PartitionKey eq 'Tenants' and (defaultDomainName eq '{0}' or customerId eq '{0}')" -f $tenantid

0 commit comments

Comments
 (0)