Skip to content

Commit f1b2680

Browse files
authored
Merge pull request KelvinTegelaar#95 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents f88496f + 0d617ff commit f1b2680

9 files changed

Lines changed: 42 additions & 29 deletions

File tree

Modules/CIPPCore/Public/Add-CIPPDelegatedPermission.ps1

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,19 @@ function Add-CIPPDelegatedPermission {
8585
$OldScope = ($CurrentDelegatedScopes | Where-Object -Property Resourceid -EQ $svcPrincipalId.id)
8686

8787
if (!$OldScope) {
88-
$Createbody = @{
89-
clientId = $ourSVCPrincipal.id
90-
consentType = 'AllPrincipals'
91-
resourceId = $svcPrincipalId.id
92-
scope = $NewScope
93-
} | ConvertTo-Json -Compress
94-
$CreateRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/oauth2PermissionGrants' -tenantid $Tenantfilter -body $Createbody -type POST -NoAuthCheck $true
95-
$Results.add("Successfully added permissions for $($svcPrincipalId.displayName)")
88+
try {
89+
$Createbody = @{
90+
clientId = $ourSVCPrincipal.id
91+
consentType = 'AllPrincipals'
92+
resourceId = $svcPrincipalId.id
93+
scope = $NewScope
94+
} | ConvertTo-Json -Compress
95+
$CreateRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/oauth2PermissionGrants' -tenantid $Tenantfilter -body $Createbody -type POST -NoAuthCheck $true
96+
$Results.add("Successfully added permissions for $($svcPrincipalId.displayName)")
97+
} catch {
98+
$Results.add("Failed to add permissions for $($svcPrincipalId.displayName): $(Get-NormalizedError -message $_.Exception.Message)")
99+
continue
100+
}
96101
} else {
97102
# Cleanup multiple scope entries and patch first id
98103
if (($OldScope.id | Measure-Object).Count -gt 1) {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-ExecAppUpload.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function Invoke-ExecAppUpload {
1414
if ($Config -and $Config.state -eq $true) {
1515
if ($env:CIPP_PROCESSOR -ne 'true') {
1616
$ProcessorFunction = [PSCustomObject]@{
17-
PartitionKey = 'Function'
18-
RowKey = 'Start-ApplicationOrchestrator'
19-
ProcessorFunction = 'Start-ApplicationOrchestrator'
17+
PartitionKey = 'Function'
18+
RowKey = 'Start-ApplicationOrchestrator'
19+
2020
}
2121
$ProcessorQueue = Get-CIPPTable -TableName 'ProcessorQueue'
2222
Add-AzDataTableEntity @ProcessorQueue -Entity $ProcessorFunction -Force

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ExecDomainAnalyser.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function Invoke-ExecDomainAnalyser {
1414
if ($Config -and $Config.state -eq $true) {
1515
if ($env:CIPP_PROCESSOR -ne 'true') {
1616
$ProcessorFunction = [PSCustomObject]@{
17-
PartitionKey = 'Function'
18-
RowKey = 'Start-DomainOrchestrator'
19-
ProcessorFunction = 'Start-DomainOrchestrator'
17+
PartitionKey = 'Function'
18+
RowKey = 'Start-DomainOrchestrator'
19+
FunctionName = 'Start-DomainOrchestrator'
2020
}
2121
$ProcessorQueue = Get-CIPPTable -TableName 'ProcessorQueue'
2222
Add-AzDataTableEntity @ProcessorQueue -Entity $ProcessorFunction -Force

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ExecStandardsRun.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Function Invoke-ExecStandardsRun {
1919
if ($Config -and $Config.state -eq $true) {
2020
if ($env:CIPP_PROCESSOR -ne 'true') {
2121
$ProcessorFunction = [PSCustomObject]@{
22-
PartitionKey = 'Function'
23-
RowKey = "Invoke-CIPPStandardsRun-$tenantfilter"
24-
ProcessorFunction = 'Invoke-CIPPStandardsRun'
25-
Parameters = [string](ConvertTo-Json -Compress -InputObject @{
22+
PartitionKey = 'Function'
23+
RowKey = "Invoke-CIPPStandardsRun-$tenantfilter"
24+
FunctionName = 'Invoke-CIPPStandardsRun'
25+
Parameters = [string](ConvertTo-Json -Compress -InputObject @{
2626
TenantFilter = $tenantfilter
2727
Force = $true
2828
})

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ListBPA.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ Function Invoke-ListBPA {
8080
$Results = [PSCustomObject]@{
8181
Data = @($Data)
8282
Columns = @($Columns)
83+
Keys = $Data | ForEach-Object {
84+
$_.PSObject.Properties |
85+
Where-Object { $_.Name -ne 'PartitionKey' -and $_.Name -ne 'RowKey' -and $_.Name -ne 'Timestamp' } |
86+
ForEach-Object { $_.Name }
87+
} | Select-Object -Unique
8388
Style = $Style
8489
}
8590

8691
if (!$Results) {
8792
$Results = @{
8893
Columns = @( value = 'Results'; name = 'Results')
8994
Data = @(@{ Results = 'The BPA has not yet run.' })
95+
Keys = @()
9096
}
9197
}
9298

Modules/CIPPCore/Public/Entrypoints/Timer Functions/Start-CIPPProcessorQueue.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function Start-CIPPProcessorQueue {
1010
$QueueItems = Get-CIPPAzDataTableEntity @QueueTable -Filter "PartitionKey eq 'Function'"
1111

1212
foreach ($QueueItem in $QueueItems) {
13-
if ($PSCmdlet.ShouldProcess("Processing function $($QueueItem.ProcessorFunction)")) {
14-
Write-Information "Running queued function $($QueueItem.ProcessorFunction)"
13+
if ($PSCmdlet.ShouldProcess("Processing function $($QueueItem.FunctionName)")) {
14+
Write-Information "Running queued function $($QueueItem.FunctionName)"
1515
if ($QueueItem.Parameters) {
1616
try {
1717
$Parameters = $QueueItem.Parameters | ConvertFrom-Json -AsHashtable
@@ -21,14 +21,14 @@ function Start-CIPPProcessorQueue {
2121
} else {
2222
$Parameters = @{}
2323
}
24-
if (Get-Command -Name $QueueItem.ProcessorFunction -Module CIPPCore -ErrorAction SilentlyContinue) {
24+
if (Get-Command -Name $QueueItem.FunctionName -Module CIPPCore -ErrorAction SilentlyContinue) {
2525
try {
26-
Invoke-Command -ScriptBlock { & $QueueItem.ProcessorFunction @Parameters }
26+
Invoke-Command -ScriptBlock { & $QueueItem.FunctionName @Parameters }
2727
} catch {
28-
Write-Warning "Failed to run function $($QueueItem.ProcessorFunction). Error: $($_.Exception.Message)"
28+
Write-Warning "Failed to run function $($QueueItem.FunctionName). Error: $($_.Exception.Message)"
2929
}
3030
} else {
31-
Write-Warning "Function $($QueueItem.ProcessorFunction) not found"
31+
Write-Warning "Function $($QueueItem.FunctionName) not found"
3232
}
3333
Remove-AzDataTableEntity @QueueTable -Entity $QueueItem
3434
}

Modules/CIPPCore/Public/Get-CIPPDomainAnalyser.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function Get-CIPPDomainAnalyser {
1717
$DomainTable = Get-CIPPTable -Table 'Domains'
1818

1919
# Get all the things
20-
20+
#Transform the tenantFilter to the GUID.
21+
$TenantFilter = (Get-Tenants -TenantFilter $tenantFilter).customerId
2122
if ($TenantFilter -ne 'AllTenants' -and ![string]::IsNullOrEmpty($TenantFilter)) {
2223
$DomainTable.Filter = "TenantGUID eq '{0}'" -f $TenantFilter
2324
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAuditLog.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ function Invoke-CIPPStandardAuditLog {
3333
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'AuditLog'
3434

3535
Write-Host ($Settings | ConvertTo-Json)
36-
$AuditLogEnabled = (New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AdminAuditLogConfig' -Select UnifiedAuditLogIngestionEnabled).UnifiedAuditLogIngestionEnabled
36+
$AuditLogEnabled = [bool](New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AdminAuditLogConfig' -Select UnifiedAuditLogIngestionEnabled).UnifiedAuditLogIngestionEnabled
3737

3838
If ($Settings.remediate -eq $true) {
3939
Write-Host 'Time to remediate'
4040

4141
$DehydratedTenant = (New-ExoRequest -tenantid $Tenant -cmdlet 'Get-OrganizationConfig' -Select IsDehydrated).IsDehydrated
42-
if ($DehydratedTenant) {
42+
if ($DehydratedTenant -eq $true) {
4343
try {
4444
New-ExoRequest -tenantid $Tenant -cmdlet 'Enable-OrganizationCustomization'
4545
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Organization customization enabled.' -sev Info
@@ -50,7 +50,7 @@ function Invoke-CIPPStandardAuditLog {
5050
}
5151

5252
try {
53-
if ($AuditLogEnabled) {
53+
if ($AuditLogEnabled -eq $true) {
5454
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Unified Audit Log already enabled.' -sev Info
5555
} else {
5656
New-ExoRequest -tenantid $Tenant -cmdlet 'Set-AdminAuditLogConfig' -cmdParams @{UnifiedAuditLogIngestionEnabled = $true }
@@ -64,7 +64,7 @@ function Invoke-CIPPStandardAuditLog {
6464
}
6565
if ($Settings.alert -eq $true) {
6666

67-
if ($AuditLogEnabled) {
67+
if ($AuditLogEnabled -eq $true) {
6868
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Unified Audit Log is enabled' -sev Info
6969
} else {
7070
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Unified Audit Log is not enabled' -sev Alert

Modules/CIPPCore/Public/Webhooks/Test-CIPPAuditLogRules.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function Test-CIPPAuditLogRules {
2121
'SAS:ProcessAuth'
2222
'deviceAuth:ReprocessTls'
2323
'Consent:Set'
24+
'Login:reprocess'
2425
)
2526

2627
$TrustedIPTable = Get-CIPPTable -TableName 'trustedIps'

0 commit comments

Comments
 (0)