File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 11function Get-CIPPSPOTenant {
22 [CmdletBinding ()]
3- Param (
3+ param (
44 [Parameter (Mandatory = $true )]
55 [string ]$TenantFilter ,
66 [string ]$SharepointPrefix
@@ -16,14 +16,33 @@ function Get-CIPPSPOTenant {
1616 $AdminUrl = " https://$ ( $tenantName ) -admin.sharepoint.com"
1717 }
1818
19+ $Table = Get-CIPPTable - tablename ' cachespotenant'
20+ $Filter = " PartitionKey eq 'Tenant' and RowKey eq '$TenantFilter ' and Timestamp gt datetime'$ ( (Get-Date ).AddHours(-1 ).ToString(' yyyy-MM-ddTHH:mm:ssZ' ) ) '"
21+ $CachedTenant = Get-CIPPAzDataTableEntity @Table - Filter $Filter
22+
23+ if ($CachedTenant -and (Test-Json $CachedTenant.JSON )) {
24+ $Results = $CachedTenant.JSON | ConvertFrom-Json
25+ return $Results
26+ }
27+
1928 # Query tenant settings
2029 $XML = @'
2130<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="SharePoint Online PowerShell (16.0.24908.0)" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="106" ObjectPathId="105" /><Query Id="107" ObjectPathId="105"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Constructor Id="105" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>
2231'@
2332 $AdditionalHeaders = @ {
2433 ' Accept' = ' application/json;odata=verbose'
2534 }
35+
2636 $Results = New-GraphPostRequest - scope " $ ( $AdminUrl ) /.default" - tenantid $TenantFilter - Uri " $ ( $SharePointInfo.AdminUrl ) /_vti_bin/client.svc/ProcessQuery" - Type POST - Body $XML - ContentType ' text/xml' - AddedHeaders $AdditionalHeaders
2737
28- $Results | Select-Object - Last 1 * , @ {n = ' SharepointPrefix' ; e = { $tenantName } }, @ {n = ' TenantFilter' ; e = { $TenantFilter } }
38+ $Results = $Results | Select-Object - Last 1 * , @ {n = ' SharepointPrefix' ; e = { $tenantName } }, @ {n = ' TenantFilter' ; e = { $TenantFilter } }
39+
40+ # Cache result
41+ $Entity = @ {
42+ PartitionKey = ' Tenant'
43+ RowKey = $TenantFilter
44+ JSON = [string ]($Results | ConvertTo-Json - Depth 10 - Compress)
45+ }
46+ Add-CIPPAzDataTableEntity @Table - Entity $Entity - Force
47+ return $Results
2948}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ function Set-CIPPSPOTenant {
2929
3030 #>
3131 [CmdletBinding (SupportsShouldProcess = $true )]
32- Param (
32+ param (
3333 [Parameter (ValueFromPipelineByPropertyName = $true , Mandatory = $true )]
3434 [string ]$TenantFilter ,
3535 [Parameter (ValueFromPipelineByPropertyName = $true , Mandatory = $true )]
@@ -65,7 +65,7 @@ function Set-CIPPSPOTenant {
6565 }
6666 $xml = @"
6767 <SetProperty Id="$x " ObjectPathId="110" Name="$Property ">
68- <Parameter Type="Boolean ">$ ( $PropertyToSet ) </Parameter>
68+ <Parameter Type="$PropertyType ">$ ( $PropertyToSet ) </Parameter>
6969 </SetProperty>
7070"@
7171 $SetProperty.Add ($xml )
You can’t perform that action at this time.
0 commit comments