Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfixes #1158

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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