Skip to content

Commit

Permalink
Merge pull request #1158 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
JohnDuprey authored Oct 17, 2024
2 parents 1d26d0e + 45c76ca commit 9483db2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
21 changes: 13 additions & 8 deletions Modules/CIPPCore/Public/Add-CIPPDelegatedPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ function Add-CIPPDelegatedPermission {
$OldScope = ($CurrentDelegatedScopes | Where-Object -Property Resourceid -EQ $svcPrincipalId.id)

if (!$OldScope) {
$Createbody = @{
clientId = $ourSVCPrincipal.id
consentType = 'AllPrincipals'
resourceId = $svcPrincipalId.id
scope = $NewScope
} | ConvertTo-Json -Compress
$CreateRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/oauth2PermissionGrants' -tenantid $Tenantfilter -body $Createbody -type POST -NoAuthCheck $true
$Results.add("Successfully added permissions for $($svcPrincipalId.displayName)")
try {
$Createbody = @{
clientId = $ourSVCPrincipal.id
consentType = 'AllPrincipals'
resourceId = $svcPrincipalId.id
scope = $NewScope
} | ConvertTo-Json -Compress
$CreateRequest = New-GraphPOSTRequest -uri 'https://graph.microsoft.com/v1.0/oauth2PermissionGrants' -tenantid $Tenantfilter -body $Createbody -type POST -NoAuthCheck $true
$Results.add("Successfully added permissions for $($svcPrincipalId.displayName)")
} catch {
$Results.add("Failed to add permissions for $($svcPrincipalId.displayName): $(Get-NormalizedError -message $_.Exception.Message)")
continue
}
} else {
# Cleanup multiple scope entries and patch first id
if (($OldScope.id | Measure-Object).Count -gt 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function Invoke-ExecAppUpload {
if ($Config -and $Config.state -eq $true) {
if ($env:CIPP_PROCESSOR -ne 'true') {
$ProcessorFunction = [PSCustomObject]@{
PartitionKey = 'Function'
RowKey = 'Start-ApplicationOrchestrator'
ProcessorFunction = 'Start-ApplicationOrchestrator'
PartitionKey = 'Function'
RowKey = 'Start-ApplicationOrchestrator'

}
$ProcessorQueue = Get-CIPPTable -TableName 'ProcessorQueue'
Add-AzDataTableEntity @ProcessorQueue -Entity $ProcessorFunction -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function Invoke-ExecDomainAnalyser {
if ($Config -and $Config.state -eq $true) {
if ($env:CIPP_PROCESSOR -ne 'true') {
$ProcessorFunction = [PSCustomObject]@{
PartitionKey = 'Function'
RowKey = 'Start-DomainOrchestrator'
ProcessorFunction = 'Start-DomainOrchestrator'
PartitionKey = 'Function'
RowKey = 'Start-DomainOrchestrator'
FunctionName = 'Start-DomainOrchestrator'
}
$ProcessorQueue = Get-CIPPTable -TableName 'ProcessorQueue'
Add-AzDataTableEntity @ProcessorQueue -Entity $ProcessorFunction -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Function Invoke-ExecStandardsRun {
if ($Config -and $Config.state -eq $true) {
if ($env:CIPP_PROCESSOR -ne 'true') {
$ProcessorFunction = [PSCustomObject]@{
PartitionKey = 'Function'
RowKey = "Invoke-CIPPStandardsRun-$tenantfilter"
ProcessorFunction = 'Invoke-CIPPStandardsRun'
Parameters = [string](ConvertTo-Json -Compress -InputObject @{
PartitionKey = 'Function'
RowKey = "Invoke-CIPPStandardsRun-$tenantfilter"
FunctionName = 'Invoke-CIPPStandardsRun'
Parameters = [string](ConvertTo-Json -Compress -InputObject @{
TenantFilter = $tenantfilter
Force = $true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function Start-CIPPProcessorQueue {
$QueueItems = Get-CIPPAzDataTableEntity @QueueTable -Filter "PartitionKey eq 'Function'"

foreach ($QueueItem in $QueueItems) {
if ($PSCmdlet.ShouldProcess("Processing function $($QueueItem.ProcessorFunction)")) {
Write-Information "Running queued function $($QueueItem.ProcessorFunction)"
if ($PSCmdlet.ShouldProcess("Processing function $($QueueItem.FunctionName)")) {
Write-Information "Running queued function $($QueueItem.FunctionName)"
if ($QueueItem.Parameters) {
try {
$Parameters = $QueueItem.Parameters | ConvertFrom-Json -AsHashtable
Expand All @@ -21,14 +21,14 @@ function Start-CIPPProcessorQueue {
} else {
$Parameters = @{}
}
if (Get-Command -Name $QueueItem.ProcessorFunction -Module CIPPCore -ErrorAction SilentlyContinue) {
if (Get-Command -Name $QueueItem.FunctionName -Module CIPPCore -ErrorAction SilentlyContinue) {
try {
Invoke-Command -ScriptBlock { & $QueueItem.ProcessorFunction @Parameters }
Invoke-Command -ScriptBlock { & $QueueItem.FunctionName @Parameters }
} catch {
Write-Warning "Failed to run function $($QueueItem.ProcessorFunction). Error: $($_.Exception.Message)"
Write-Warning "Failed to run function $($QueueItem.FunctionName). Error: $($_.Exception.Message)"
}
} else {
Write-Warning "Function $($QueueItem.ProcessorFunction) not found"
Write-Warning "Function $($QueueItem.FunctionName) not found"
}
Remove-AzDataTableEntity @QueueTable -Entity $QueueItem
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Test-CIPPAuditLogRules {
'SAS:ProcessAuth'
'deviceAuth:ReprocessTls'
'Consent:Set'
'Login:reprocess'
)

$TrustedIPTable = Get-CIPPTable -TableName 'trustedIps'
Expand Down

0 comments on commit 9483db2

Please sign in to comment.