Skip to content

Commit

Permalink
Merge branch 'KelvinTegelaar:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
BNWEIN authored Sep 5, 2023
2 parents 0dc4067 + cbe6985 commit 8b106f9
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 459 deletions.
10 changes: 7 additions & 3 deletions ExecCPVPermissions/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ $GraphRequest = $ExpectedPermissions.requiredResourceAccess | ForEach-Object {
}
}

try {
$ourSVCPrincipal = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($ENV:applicationid)')" -tenantid $Tenantfilter
$CurrentRoles = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals/$($ourSVCPrincipal.id)/appRoleAssignments" -tenantid $tenantfilter

$ourSVCPrincipal = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($ENV:applicationid)')" -tenantid $Tenantfilter

}
catch {
#this try catch exists because of 500 errors when the app principal does not exist. :)
}
# if the app svc principal exists, consent app permissions
$apps = $ExpectedPermissions
#get current roles
$CurrentRoles = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/servicePrincipals/$($ourSVCPrincipal.id)/appRoleAssignments" -tenantid $tenantfilter
#If
$Grants = foreach ($App in $apps.requiredResourceAccess) {
try {
Expand Down
27 changes: 14 additions & 13 deletions ExecExtensionMapping/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ if ($Request.Query.List) {
$Tenants = Get-Tenants
#Get available halo clients
$Table = Get-CIPPTable -TableName Extensionsconfig
$Configuration = ((Get-AzDataTableEntity @Table).config | ConvertFrom-Json).HaloPSA
$Token = Get-HaloToken -configuration $Configuration
$i = 1
$RawHaloClients = do {
$Result = Invoke-RestMethod -Uri "$($Configuration.ResourceURL)/Client?page_no=$i&page_size=999&pageinate=true" -ContentType 'application/json' -Method GET -Headers @{Authorization = "Bearer $($token.access_token)" }
$Result.clients | Select-Object * -ExcludeProperty logo
$i++
$pagecount = [Math]::Ceiling($Result.record_count / 999)
} while ($i -le $pagecount)
try {
$Configuration = ((Get-AzDataTableEntity @Table).config | ConvertFrom-Json -ErrorAction Stop).HaloPSA
$Token = Get-HaloToken -configuration $Configuration
$i = 1
$RawHaloClients = do {
$Result = Invoke-RestMethod -Uri "$($Configuration.ResourceURL)/Client?page_no=$i&page_size=999&pageinate=true" -ContentType 'application/json' -Method GET -Headers @{Authorization = "Bearer $($token.access_token)" }
$Result.clients | Select-Object * -ExcludeProperty logo
$i++
$pagecount = [Math]::Ceiling($Result.record_count / 999)
} while ($i -le $pagecount)
} catch { $RawHaloClients = @() }
$HaloClients = $RawHaloClients | ForEach-Object {
[PSCustomObject]@{
label = $_.name
Expand Down Expand Up @@ -59,12 +61,11 @@ try {
'HaloPSAName' = "$($mapping.value.label)"
}
Add-AzDataTableEntity @Table -Entity $AddObject -Force
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Added mapping for $($mapping.name)." -Sev 'Info'
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Added mapping for $($mapping.name)." -Sev 'Info'
}
$body = [pscustomobject]@{'Results' = "Successfully edited mapping table." }
$body = [pscustomobject]@{'Results' = 'Successfully edited mapping table.' }
}
}
catch {
} catch {
Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "mapping API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}
Expand Down
75 changes: 0 additions & 75 deletions ExecMaintenanceScripts/Scripts/Clear-TokenCache.ps1

This file was deleted.

174 changes: 0 additions & 174 deletions ExecMaintenanceScripts/Scripts/Migrate-CippStorage.ps1

This file was deleted.

Loading

0 comments on commit 8b106f9

Please sign in to comment.