-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1148 from JohnDuprey/dev
Bugfixes
- Loading branch information
Showing
4 changed files
with
39 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 13 additions & 11 deletions
24
Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecAddMultiTenantApp.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
function Push-ExecAddMultiTenantApp($QueueItem, $TriggerMetadata) { | ||
function Push-ExecAddMultiTenantApp { | ||
<# | ||
.FUNCTIONALITY | ||
Entrypoint | ||
#> | ||
[CmdletBinding()] | ||
param($Item) | ||
try { | ||
$Queueitem = $QueueItem | ConvertTo-Json -Depth 10 | ConvertFrom-Json | ||
Write-Host "$($Queueitem | ConvertTo-Json -Depth 10)" | ||
$ServicePrincipalList = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals?`$select=AppId,id,displayName&`$top=999" -tenantid $Queueitem.Tenant | ||
if ($Queueitem.AppId -Notin $ServicePrincipalList.appId) { | ||
$PostResults = New-GraphPostRequest 'https://graph.microsoft.com/beta/servicePrincipals' -type POST -tenantid $queueitem.tenant -body "{ `"appId`": `"$($Queueitem.appId)`" }" | ||
Write-LogMessage -message "Added $($Queueitem.AppId) to tenant $($Queueitem.Tenant)" -tenant $Queueitem.Tenant -API 'Add Multitenant App' -sev Info | ||
$Item = $Item | ConvertTo-Json -Depth 10 | ConvertFrom-Json | ||
Write-Host "$($Item | ConvertTo-Json -Depth 10)" | ||
$ServicePrincipalList = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals?`$select=AppId,id,displayName&`$top=999" -tenantid $Item.Tenant | ||
if ($Item.AppId -Notin $ServicePrincipalList.appId) { | ||
$PostResults = New-GraphPostRequest 'https://graph.microsoft.com/beta/servicePrincipals' -type POST -tenantid $Item.tenant -body "{ `"appId`": `"$($Item.appId)`" }" | ||
Write-LogMessage -message "Added $($Item.AppId) to tenant $($Item.Tenant)" -tenant $Item.Tenant -API 'Add Multitenant App' -sev Info | ||
} else { | ||
Write-LogMessage -message "This app already exists in tenant $($Queueitem.Tenant). We're adding the required permissions." -tenant $Queueitem.Tenant -API 'Add Multitenant App' -sev Info | ||
Write-LogMessage -message "This app already exists in tenant $($Item.Tenant). We're adding the required permissions." -tenant $Item.Tenant -API 'Add Multitenant App' -sev Info | ||
} | ||
Add-CIPPApplicationPermission -RequiredResourceAccess ($queueitem.applicationResourceAccess) -ApplicationId $queueitem.AppId -Tenantfilter $Queueitem.Tenant | ||
Add-CIPPDelegatedPermission -RequiredResourceAccess ($queueitem.DelegateResourceAccess) -ApplicationId $queueitem.AppId -Tenantfilter $Queueitem.Tenant | ||
Add-CIPPApplicationPermission -RequiredResourceAccess ($Item.applicationResourceAccess) -ApplicationId $Item.AppId -Tenantfilter $Item.Tenant | ||
Add-CIPPDelegatedPermission -RequiredResourceAccess ($Item.DelegateResourceAccess) -ApplicationId $Item.AppId -Tenantfilter $Item.Tenant | ||
} catch { | ||
Write-LogMessage -message "Error adding application to tenant $($Queueitem.Tenant) - $($_.Exception.Message)" -tenant $Queueitem.Tenant -API 'Add Multitenant App' -sev Error | ||
Write-LogMessage -message "Error adding application to tenant $($Item.Tenant) - $($_.Exception.Message)" -tenant $Item.Tenant -API 'Add Multitenant App' -sev Error | ||
} | ||
} |
11 changes: 6 additions & 5 deletions
11
Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecApplicationCopy.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
function Push-ExecApplicationCopy($QueueItem, $TriggerMetadata) { | ||
function Push-ExecApplicationCopy { | ||
<# | ||
.FUNCTIONALITY | ||
Entrypoint | ||
#> | ||
[CmdletBinding()] | ||
param($Item) | ||
try { | ||
$Queueitem = $QueueItem | ConvertTo-Json -Depth 10 | ConvertFrom-Json | ||
Write-Host "$($Queueitem | ConvertTo-Json -Depth 10)" | ||
New-CIPPApplicationCopy -App $queueitem.AppId -Tenant $Queueitem.Tenant | ||
Write-Host "$($Item | ConvertTo-Json -Depth 10)" | ||
New-CIPPApplicationCopy -App $Item.AppId -Tenant $Item.Tenant | ||
} catch { | ||
Write-LogMessage -message "Error adding application to tenant $($Queueitem.Tenant) - $($_.Exception.Message)" -tenant $Queueitem.Tenant -API 'Add Multitenant App' -sev Error | ||
Write-LogMessage -message "Error adding application to tenant $($Item.Tenant) - $($_.Exception.Message)" -tenant $Item.Tenant -API 'Add Multitenant App' -sev Error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters