Skip to content

Commit

Permalink
Merge pull request #62 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
BNWEIN authored Apr 4, 2024
2 parents 121e938 + d352ef2 commit d15cd10
Show file tree
Hide file tree
Showing 218 changed files with 169 additions and 303 deletions.
2 changes: 1 addition & 1 deletion Modules/CIPPCore/Public/Add-CIPPApplicationPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Add-CIPPApplicationPermission {
foreach ($Grant in $Grants) {
try {
$SettingsRequest = New-GraphPOSTRequest -body ($Grant | ConvertTo-Json) -uri "https://graph.microsoft.com/beta/servicePrincipals/$($ourSVCPrincipal.id)/appRoleAssignedTo" -tenantid $Tenantfilter -type POST
$counter ++
$counter++
} catch {
$Results.add("Failed to grant $($Grant.appRoleId) to $($Grant.resourceId): $($_.Exception.Message)") | Out-Null
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Remove-CippQueue {
function Invoke-RemoveCippQueue {
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function Push-UpdateTenants {
Param($Item)
$QueueReference = 'UpdateTenants'
$RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -ne 'Completed' -and $_.Status -ne 'Failed' }
if ($RunningQueue) {
Write-Host 'Update Tenants already running'
return
}
$Queue = New-CippQueueEntry -Name 'Update Tenants' -Reference $QueueReference
try {
Update-CippQueueEntry -RowKey $Queue.RowKey -Status 'Running'
Get-Tenants | Out-Null
Update-CippQueueEntry -RowKey $Queue.RowKey -Status 'Completed'
} catch {
Write-Host "Queue Error: $($_.Exception.Message)"
Update-CippQueueEntry -RowKey $Queue.RowKey -Status 'Failed'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ Function Invoke-ListTenants {
StatusCode = [HttpStatusCode]::OK
Body = $GraphRequest
})
$InputObject = [PSCustomObject]@{
OrchestratorName = 'UpdateTenantsOrchestrator'
Batch = @(@{'FunctionName' = 'UpdateTenants' })
}
#Write-Host ($InputObject | ConvertTo-Json)
$InstanceId = Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5)
exit
}

try {
$tenantfilter = $Request.Query.TenantFilter
$Tenants = Get-Tenants -IncludeErrors
$Tenants = Get-Tenants -IncludeErrors -SkipDomains

if ($null -eq $TenantFilter -or $TenantFilter -eq 'null') {
$TenantList = [system.collections.generic.list[object]]::new()
if ($Request.Query.AllTenantSelector -eq $true) {
if ($Request.Query.AllTenantSelector -eq $true) {
$TenantList.Add(@{
customerId = 'AllTenants'
defaultDomainName = 'AllTenants'
Expand All @@ -55,7 +61,7 @@ Function Invoke-ListTenants {
Write-LogMessage -user $request.headers.'x-ms-client-principal' -tenant $Tenantfilter -API $APINAME -message 'Listed Tenant Details' -Sev 'Debug'
} catch {
Write-LogMessage -user $request.headers.'x-ms-client-principal' -tenant $Tenantfilter -API $APINAME -message "List Tenant failed. The error is: $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{
$body = [pscustomobject]@{
'Results' = "Failed to retrieve tenants: $($_.Exception.Message)"
defaultDomainName = ''
displayName = 'Failed to retrieve tenants. Perform a permission check.'
Expand All @@ -68,6 +74,6 @@ Function Invoke-ListTenants {
StatusCode = [HttpStatusCode]::OK
Body = @($Body)
})


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using namespace System.Net

Function Invoke-ExecDeleteGDAPRelationship {
<#
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'

# Interact with query parameters or the body of the request.
$GDAPID = $request.query.GDAPId
try {
$DELETE = New-GraphPostRequest -NoAuthCheck $True -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships/$($GDAPID)/requests" -type POST -body '{"action":"terminate"}' -tenantid $env:TenantID
$Results = [pscustomobject]@{'Results' = "Success. GDAP relationship for $($GDAPID) been revoked" }
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Success. GDAP relationship for $($GDAPID) been revoked" -Sev 'Info'

} catch {
$Results = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $Results
})

}

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions Modules/CIPPCore/Public/Entrypoints/Invoke-ExecGDAPInviteQueue.ps1

This file was deleted.

33 changes: 0 additions & 33 deletions Modules/CIPPCore/Public/Entrypoints/Invoke-ExecGDAPMigration.ps1

This file was deleted.

This file was deleted.

Loading

0 comments on commit d15cd10

Please sign in to comment.