Skip to content

Commit d6d3352

Browse files
authored
Merge pull request KelvinTegelaar#976 from KelvinTegelaar/dev
Dev to hotfix
2 parents 1bfb5bd + 2513fbb commit d6d3352

14 files changed

Lines changed: 238 additions & 175 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function Get-CIPPAlertDepTokenExpiry {
1616
$DepTokens = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/depOnboardingSettings' -tenantid $TenantFilter).value
1717
$AlertData = foreach ($Dep in $DepTokens) {
1818
if ($Dep.tokenExpirationDateTime -lt (Get-Date).AddDays(30) -and $Dep.tokenExpirationDateTime -gt (Get-Date).AddDays(-7)) {
19-
'Apple Device Enrollment Program token expiring on {0}' -f $Dep.tokenExpirationDateTime
19+
$Message = 'Apple Device Enrollment Program token expiring on {0}' -f $Dep.tokenExpirationDateTime
20+
$Dep | Select-Object -Property tokenName, @{Name = 'Message'; Expression = { $Message } }
2021
}
2122
}
2223
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ function Get-CIPPAlertVppTokenExpiry {
1515
$VppTokens = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/deviceAppManagement/vppTokens' -tenantid $TenantFilter).value
1616
$AlertData = foreach ($Vpp in $VppTokens) {
1717
if ($Vpp.state -ne 'valid') {
18-
'Apple Volume Purchase Program Token is not valid, new token required'
18+
$Message = 'Apple Volume Purchase Program Token is not valid, new token required'
19+
$Vpp | Select-Object -Property organizationName, appleId, vppTokenAccountType, @{Name = 'Message'; Expression = { $Message } }
1920
}
2021
if ($Vpp.expirationDateTime -lt (Get-Date).AddDays(30) -and $Vpp.expirationDateTime -gt (Get-Date).AddDays(-7)) {
21-
'Apple Volume Purchase Program token expiring on {0}' -f $Vpp.expirationDateTime
22+
$Message = 'Apple Volume Purchase Program token expiring on {0}' -f $Vpp.expirationDateTime
23+
$Vpp | Select-Object -Property organizationName, appleId, vppTokenAccountType, @{Name = 'Message'; Expression = { $Message } }
2224
}
2325
}
2426
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
@@ -28,4 +30,4 @@ function Get-CIPPAlertVppTokenExpiry {
2830
} catch {
2931
# Error handling
3032
}
31-
}
33+
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecExtensionMapping.ps1 renamed to Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ExecExtensionMapping.ps1

File renamed without changes.

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecExtensionSync.ps1 renamed to Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ExecExtensionSync.ps1

File renamed without changes.

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecExtensionTest.ps1 renamed to Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ExecExtensionTest.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ Function Invoke-ExecExtensionTest {
4949
'Hudu' {
5050
Connect-HuduAPI -configuration $Configuration.Hudu
5151
$Version = Get-HuduAppInfo
52-
Write-Host ($Version | ConvertTo-Json)
53-
$Results = [pscustomobject]@{'Results' = ('Successfully Connected to Hudu, version: {0}' -f $Version.version) }
52+
if ($Version.version) {
53+
$Results = [pscustomobject]@{'Results' = ('Successfully Connected to Hudu, version: {0}' -f $Version.version) }
54+
} else {
55+
$Results = [pscustomobject]@{'Results' = 'Failed to connect to Hudu' }
56+
}
5457
}
5558
}
5659
} catch {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecExtensionsConfig.ps1 renamed to Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ExecExtensionsConfig.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ Function Invoke-ExecExtensionsConfig {
5656
$null = Set-AzKeyVaultSecret -VaultName $ENV:WEBSITE_DEPLOYMENT_ID -Name $APIKey -SecretValue (ConvertTo-SecureString -AsPlainText -Force -String $Request.Body.$APIKey.APIKey)
5757
}
5858
}
59-
$Request.Body.$APIKey.APIKey = 'SentToKeyVault'
59+
if ($Request.Body.$APIKey.PSObject.Properties -notcontains 'APIKey') {
60+
a$Request.Body.$APIKey | Add-Member -MemberType NoteProperty -Name APIKey -Value 'SentToKeyVault' -PassThru
61+
} else {
62+
$Request.Body.$APIKey.APIKey = 'SentToKeyVault'
63+
}
6064
}
6165
$Request.Body.$APIKey = $Request.Body.$APIKey | Select-Object * -ExcludeProperty ResetPassword
6266
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ListExtensionSync {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint
7+
.ROLE
8+
CIPP.Extension.Read
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $TriggerMetadata.FunctionName
14+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15+
16+
# Write to the Azure Functions log stream.
17+
Write-Host 'PowerShell HTTP trigger function processed a request.'
18+
$ScheduledTasksTable = Get-CIPPTable -TableName 'ScheduledTasks'
19+
$ScheduledTasks = Get-CIPPAzDataTableEntity @ScheduledTasksTable -Filter 'Hidden eq true' | Where-Object { $_.Command -match 'CippExtension' }
20+
21+
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList
22+
$TenantList = Get-Tenants -IncludeErrors
23+
$AllTasksArrayList = [system.collections.generic.list[object]]::new()
24+
25+
foreach ($Task in $ScheduledTasks) {
26+
if ($Task.Results -and (Test-Json -Json $Task.Results -ErrorAction SilentlyContinue)) {
27+
$Results = $Task.Results | ConvertFrom-Json
28+
} else {
29+
$Results = $Task.Results
30+
}
31+
32+
$TaskEntry = [PSCustomObject]@{
33+
RowKey = $Task.RowKey
34+
PartitionKey = $Task.PartitionKey
35+
Tenant = $Task.Tenant
36+
Name = $Task.Name
37+
SyncType = $Task.SyncType
38+
ScheduledTime = $Task.ScheduledTime
39+
ExecutedTime = $Task.ExecutedTime
40+
RepeatsEvery = $Task.Recurrence
41+
Results = $Results
42+
}
43+
44+
if ($AllowedTenants -notcontains 'AllTenants') {
45+
$Tenant = $TenantList | Where-Object -Property defaultDomainName -EQ $Task.Tenant
46+
if ($AllowedTenants -contains $Tenant.customerId) {
47+
$AllTasksArrayList.Add($TaskEntry)
48+
}
49+
} else {
50+
$AllTasksArrayList.Add($TaskEntry)
51+
}
52+
}
53+
Write-Host ($AllTasksArrayList | ConvertTo-Json -Depth 5 -Compress)
54+
# Associate values to output bindings by calling 'Push-OutputBinding'.
55+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
56+
StatusCode = [HttpStatusCode]::OK
57+
Body = ConvertTo-Json -Depth 5 -InputObject $($AllTasksArrayList)
58+
})
59+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function New-ExoRequest ($tenantid, $cmdlet, $cmdParams, $useSystemMailbox, $Anc
2323
if ($cmdparams.anr) { $Anchor = $cmdparams.anr }
2424
if ($cmdparams.User) { $Anchor = $cmdparams.User }
2525
if ($cmdparams.mailbox) { $Anchor = $cmdparams.mailbox }
26-
if ($cmdlet -eq 'Set-AdminAuditLogConfig') { $anchor = "UPN:SystemMailbox{8cc370d3-822a-4ab8-a926-bb94bd0641a9}@$($OnMicrosoft)" }
26+
if ($cmdlet -in 'Set-AdminAuditLogConfig', 'Get-AdminAuditLogConfig', 'Enable-OrganizationCustomization', 'Get-OrganizationConfig') { $anchor = "UPN:SystemMailbox{8cc370d3-822a-4ab8-a926-bb94bd0641a9}@$($OnMicrosoft)" }
2727
if (!$Anchor -or $useSystemMailbox) {
2828
if (!$Tenant.initialDomainName -or $Tenant.initialDomainName -notlike '*onmicrosoft.com*') {
2929
$OnMicrosoft = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/domains?$top=999' -tenantid $tenantid -NoAuthCheck $NoAuthCheck | Where-Object -Property isInitial -EQ $true).id
@@ -78,4 +78,4 @@ function New-ExoRequest ($tenantid, $cmdlet, $cmdParams, $useSystemMailbox, $Anc
7878
} else {
7979
Write-Error 'Not allowed. You cannot manage your own tenant or tenants not under your scope'
8080
}
81-
}
81+
}

Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,17 @@ function Get-GraphRequestList {
285285
if (!$QueueThresholdExceeded) {
286286
$GraphRequestResults = New-GraphGetRequest @GraphRequest -ErrorAction Stop | Select-Object *, @{l = 'Tenant'; e = { $TenantFilter } }, @{l = 'CippStatus'; e = { 'Good' } }
287287
if ($ReverseTenantLookup -and $GraphRequestResults) {
288-
$TenantInfo = $GraphRequestResults.$ReverseTenantLookupProperty | Sort-Object -Unique | ForEach-Object {
289-
New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/findTenantInformationByTenantId(tenantId='$_')" -noauthcheck $true -asApp:$true -tenant $env:TenantId
290-
}
291-
foreach ($Result in $GraphRequestResults) {
292-
$Result | Select-Object @{n = 'TenantInfo'; e = { $TenantInfo | Where-Object { $Result.$ReverseTenantLookupProperty -eq $_.tenantId } } }, *
288+
$ReverseLookupRequests = $GraphRequestResults.$ReverseTenantLookupProperty | Sort-Object -Unique | ForEach-Object {
289+
@{
290+
id = $_
291+
url = "tenantRelationships/findTenantInformationByTenantId(tenantId='$_')"
292+
method = 'GET'
293+
}
293294
}
295+
$TenantInfo = New-GraphBulkRequest -Requests @($ReverseLookupRequests) -tenantid $env:TenantId -NoAuthCheck $true -asapp $true
296+
297+
$GraphRequestResults | Select-Object @{n = 'TenantInfo'; e = { Get-GraphBulkResultByID -Results @($TenantInfo) -ID $_.$ReverseTenantLookupProperty } }, *
298+
294299
} else {
295300
$GraphRequestResults
296301
}
@@ -306,4 +311,4 @@ function Get-GraphRequestList {
306311
$_.Data | ConvertFrom-Json
307312
}
308313
}
309-
}
314+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function Get-HuduLinkBlock($URL, $Icon, $Title) {
2-
return "<button class='button' style='background-color: var(--primary)' role='button'><a style='color: white;' role='button' href=$URL target=_blank><i class=`"$Icon me-2`" />$Title</a></button>"
2+
return '<button class="button" style="background-color: var(--primary)" role="button"><a style="color: white;" role="button" href="{0}" target="_blank"><i class="{1} me-2"></i>{2}</a></button>' -f $URL, $Icon, $Title
33
}

0 commit comments

Comments
 (0)