Skip to content

Commit c9a37ec

Browse files
authored
Merge pull request #326 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 0205070 + c72aef9 commit c9a37ec

File tree

11 files changed

+45
-21
lines changed

11 files changed

+45
-21
lines changed

CIPP-Permissions.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@
225225
"Name": "Organization.ReadWrite.All",
226226
"Description": "Allows the app to read and write the organization and related resources, on your behalf. Related resources include things like subscribed skus and tenant branding information."
227227
},
228+
{
229+
"Id": "346c19ff-3fb2-4e81-87a0-bac9e33990c1",
230+
"Name": "OrgSettings-Forms.ReadWrite.All",
231+
"Description": "Allows the app to read and write organization-wide Microsoft Forms settings on your behalf."
232+
},
228233
{
229234
"Id": "e67e6727-c080-415e-b521-e3f35d5248e9",
230235
"Name": "PeopleSettings.ReadWrite.All",
@@ -577,6 +582,11 @@
577582
"Name": "Organization.ReadWrite.All",
578583
"Description": "Allows the app to read and write the organization and related resources, without a signed-in user. Related resources include things like subscribed skus and tenant branding information."
579584
},
585+
{
586+
"Id": "2cb92fee-97a3-4034-8702-24a6f5d0d1e9",
587+
"Name": "OrgSettings-Forms.ReadWrite.All",
588+
"Description": "Allows the app to read and write organization-wide Microsoft Forms settings, without a signed-in user."
589+
},
580590
{
581591
"Id": "b6890674-9dd5-4e42-bb15-5af07f541ae1",
582592
"Name": "PeopleSettings.ReadWrite.All",
@@ -637,6 +647,11 @@
637647
"Name": "ReportSettings.ReadWrite.All",
638648
"Description": "Allows the app to read and update all admin report settings, such as whether to display concealed information in reports, without a signed-in user."
639649
},
650+
{
651+
"Id": "025d3225-3f02-4882-b4c0-cd5b541a4e80",
652+
"Name": "RoleManagement.ReadWrite.Exchange",
653+
"Description": "Allows the app to read and manage the role-based access control (RBAC) settings for your organization's Exchange Online service, without a signed-in user. This includes reading, creating, updating, and deleting Exchange management role definitions, role groups, role group membership, role assignments, management scopes, and role assignment policies."
654+
},
640655
{
641656
"Id": "04c55753-2244-4c25-87fc-704ab82a4f69",
642657
"Name": "SecurityAnalyzedMessage.ReadWrite.All",

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ function Get-CIPPAlertSharepointQuota {
1111
$TenantFilter
1212
)
1313
Try {
14-
$SharePointInfo = Get-SharePointAdminLink -Public $false
15-
$sharepointQuota = (New-GraphGetRequest -scope "$($SharePointInfo.AdminUrl)/.default" -tenantid $TenantFilter -uri "$($SharePointInfo.AdminUrl)/_api/StorageQuotas()?api-version=1.3.2").value
14+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
15+
$extraHeaders = @{
16+
'Accept' = 'application/json'
17+
}
18+
$sharepointQuota = (New-GraphGetRequest -extraHeaders $extraHeaders -scope "$($SharePointInfo.AdminUrl)/.default" -tenantid $TenantFilter -uri "$($SharePointInfo.AdminUrl)/_api/StorageQuotas()?api-version=1.3.2")
1619
} catch {
1720
return
1821
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Invoke-ListSharepointAdminUrl {
1919
if ($Tenant.SharepointAdminUrl) {
2020
$AdminUrl = $Tenant.SharepointAdminUrl
2121
} else {
22-
$SharePointInfo = Get-SharePointAdminLink -Public $false
22+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
2323
$Tenant | Add-Member -MemberType NoteProperty -Name SharepointAdminUrl -Value $SharePointInfo.AdminUrl
2424
$Table = Get-CIPPTable -TableName 'Tenants'
2525
Add-CIPPAzDataTableEntity @Table -Entity $Tenant -Force

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ Function Invoke-ListSharepointQuota {
2121
$UsedStoragePercentage = 'Not Supported'
2222
} else {
2323
try {
24-
$SharePointInfo = Get-SharePointAdminLink -Public $false
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
24+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
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/Get-CIPPSPOTenant.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function Get-CIPPSPOTenant {
88

99
if (!$SharepointPrefix) {
1010
# get sharepoint admin site
11-
$SharePointInfo = Get-SharePointAdminLink -Public $false
11+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
1212
$tenantName = $SharePointInfo.TenantName
1313
$AdminUrl = $SharePointInfo.AdminUrl
1414
} else {

Modules/CIPPCore/Public/GraphHelper/Get-SharePointAdminLink.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Get-SharePointAdminLink {
44
Internal
55
#>
66
[CmdletBinding()]
7-
param ($Public)
7+
param ($Public, $TenantFilter)
88

99
if ($Public) {
1010
# Do it through domain discovery, unreliable
@@ -42,10 +42,10 @@ function Get-SharePointAdminLink {
4242

4343
# Get the onmicrosoft.com domain from the response
4444
$TenantDomains = $Response.Envelope.body.GetFederationInformationResponseMessage.response.Domains.Domain | Sort-Object
45-
$OnMicrosoftDomains = $TenantDomains | Where-Object { $_ -like "*.onmicrosoft.com" }
45+
$OnMicrosoftDomains = $TenantDomains | Where-Object { $_ -like '*.onmicrosoft.com' }
4646

4747
if ($OnMicrosoftDomains.Count -eq 0) {
48-
throw "Could not find onmicrosoft.com domain through autodiscover"
48+
throw 'Could not find onmicrosoft.com domain through autodiscover'
4949
} elseif ($OnMicrosoftDomains.Count -gt 1) {
5050
throw "Multiple onmicrosoft.com domains found through autodiscover. Cannot determine the correct one: $($OnMicrosoftDomains -join ', ')"
5151
} else {
@@ -61,8 +61,8 @@ function Get-SharePointAdminLink {
6161

6262
# Return object with all needed properties
6363
return [PSCustomObject]@{
64-
AdminUrl = "https://$tenantName-admin.sharepoint.com"
65-
TenantName = $tenantName
66-
SharePointUrl = "https://$tenantName.sharepoint.com"
64+
AdminUrl = "https://$tenantName-admin.sharepoint.com"
65+
TenantName = $tenantName
66+
SharePointUrl = "https://$tenantName.sharepoint.com"
6767
}
68-
}
68+
}

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

Modules/CIPPCore/Public/New-CIPPSharepointSite.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function New-CIPPSharepointSite {
6666
$Headers
6767
)
6868

69-
$SharePointInfo = Get-SharePointAdminLink -Public $false
69+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
7070
$SitePath = $SiteName -replace ' ' -replace '[^A-Za-z0-9-]'
7171
$SiteUrl = "https://$($SharePointInfo.TenantName).sharepoint.com/sites/$SitePath"
7272

Modules/CIPPCore/Public/Request-CIPPSPOPersonalSite.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ function Request-CIPPSPOPersonalSite {
3737
</Request>
3838
"@
3939

40-
$SharePointInfo = Get-SharePointAdminLink -Public $false
41-
40+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
4241
try {
4342
$Request = New-GraphPostRequest -scope "$($SharePointInfo.AdminUrl)/.default" -tenantid $TenantFilter -Uri "$($SharePointInfo.AdminUrl)/_vti_bin/client.svc/ProcessQuery" -Type POST -Body $XML -ContentType 'text/xml'
4443
if (!$Request.IsComplete) { throw }

Modules/CIPPCore/Public/Set-CIPPSPOTenant.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function Set-CIPPSPOTenant {
4444
process {
4545
if (!$SharepointPrefix) {
4646
# get sharepoint admin site
47-
$SharePointInfo = Get-SharePointAdminLink -Public $false
47+
$SharePointInfo = Get-SharePointAdminLink -Public $false -tenantFilter $TenantFilter
4848
$AdminUrl = $SharePointInfo.AdminUrl
4949
} else {
5050
$tenantName = $SharepointPrefix

0 commit comments

Comments
 (0)