forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
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 KelvinTegelaar#495 from KelvinTegelaar/dev
hotfix for two small bugs that annoy me
- Loading branch information
Showing
4 changed files
with
63 additions
and
62 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
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
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,85 +1,83 @@ | ||
using namespace System.Net | ||
using namespace System.Net | ||
|
||
Function Invoke-ListBPA { | ||
Function Invoke-ListBPA { | ||
<# | ||
.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" | ||
$APIName = $TriggerMetadata.FunctionName | ||
# Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug" | ||
|
||
$Table = get-cipptable 'cachebpav2' | ||
$name = $Request.query.Report | ||
if ($name -eq $null) { $name = 'CIPP Best Practices v1.0 - Table view' } | ||
$Table = get-cipptable 'cachebpav2' | ||
$name = $Request.query.Report | ||
if ($name -eq $null) { $name = 'CIPP Best Practices v1.0 - Table view' } | ||
|
||
# Get all possible JSON files for reports, find the correct one, select the Columns | ||
$JSONFields = @() | ||
$Columns = $null | ||
$CippRoot = (Get-Item $PSScriptRoot).Parent.FullName | ||
(Get-ChildItem -Path "$CippRoot\Config\*.BPATemplate.json" -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object { | ||
$Template = $(Get-Content $_) | ConvertFrom-Json | ||
if ($Template.Name -eq $NAME) { | ||
$JSONFields = $Template.Fields | Where-Object { $_.StoreAs -eq 'JSON' } | ForEach-Object { $_.name } | ||
$Columns = $Template.fields.FrontendFields | Where-Object -Property name -NE $null | ||
$Style = $Template.Style | ||
} | ||
}) | ||
# Get all possible JSON files for reports, find the correct one, select the Columns | ||
$JSONFields = @() | ||
$Columns = $null | ||
(Get-ChildItem -Path 'Config\*.BPATemplate.json' -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object { | ||
$Template = $(Get-Content $_) | ConvertFrom-Json | ||
if ($Template.Name -eq $NAME) { | ||
$JSONFields = $Template.Fields | Where-Object { $_.StoreAs -eq 'JSON' } | ForEach-Object { $_.name } | ||
$Columns = $Template.fields.FrontendFields | Where-Object -Property name -NE $null | ||
$Style = $Template.Style | ||
} | ||
}) | ||
|
||
|
||
if ($Request.query.tenantFilter -ne 'AllTenants' -and $Style -eq 'Tenant') { | ||
$mergedObject = New-Object pscustomobject | ||
if ($Request.query.tenantFilter -ne 'AllTenants' -and $Style -eq 'Tenant') { | ||
$mergedObject = New-Object pscustomobject | ||
|
||
$Data = (Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq '$($Request.query.tenantFilter)'") | ForEach-Object { | ||
$row = $_ | ||
$JSONFields | ForEach-Object { | ||
$jsonContent = $row.$_ | ||
if ($jsonContent -ne $null -and $jsonContent -ne 'FAILED') { | ||
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15 | ||
$Data = (Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq '$($Request.query.tenantFilter)'") | ForEach-Object { | ||
$row = $_ | ||
$JSONFields | ForEach-Object { | ||
$jsonContent = $row.$_ | ||
if ($jsonContent -ne $null -and $jsonContent -ne 'FAILED') { | ||
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15 | ||
} | ||
} | ||
$row.PSObject.Properties | ForEach-Object { | ||
$mergedObject | Add-Member -NotePropertyName $_.Name -NotePropertyValue $_.Value -Force | ||
} | ||
} | ||
$row.PSObject.Properties | ForEach-Object { | ||
$mergedObject | Add-Member -NotePropertyName $_.Name -NotePropertyValue $_.Value -Force | ||
} | ||
} | ||
|
||
$Data = $mergedObject | ||
} | ||
else { | ||
$Tenants = Get-Tenants -IncludeErrors | ||
$Data = (Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq '$NAME'") | ForEach-Object { | ||
$row = $_ | ||
$JSONFields | ForEach-Object { | ||
$jsonContent = $row.$_ | ||
if ($jsonContent -ne $null -and $jsonContent -ne 'FAILED') { | ||
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15 | ||
$Data = $mergedObject | ||
} else { | ||
$Tenants = Get-Tenants -IncludeErrors | ||
$Data = (Get-CIPPAzDataTableEntity @Table -Filter "RowKey eq '$NAME'") | ForEach-Object { | ||
$row = $_ | ||
$JSONFields | ForEach-Object { | ||
$jsonContent = $row.$_ | ||
if ($jsonContent -ne $null -and $jsonContent -ne 'FAILED') { | ||
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15 | ||
} | ||
} | ||
$row | Where-Object -Property PartitionKey -In $Tenants.customerId | ||
} | ||
$row | Where-Object -Property PartitionKey -In $Tenants.customerId | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
$Results = [PSCustomObject]@{ | ||
Data = $Data | ||
Columns = $Columns | ||
Style = $Style | ||
} | ||
$Results = [PSCustomObject]@{ | ||
Data = $Data | ||
Columns = $Columns | ||
Style = $Style | ||
} | ||
|
||
if (!$Results) { | ||
$Results = @{ | ||
Columns = @( value = 'Results'; name = 'Results') | ||
Data = @(@{ Results = 'The BPA has not yet run.' }) | ||
if (!$Results) { | ||
$Results = @{ | ||
Columns = @( value = 'Results'; name = 'Results') | ||
Data = @(@{ Results = 'The BPA has not yet run.' }) | ||
} | ||
} | ||
} | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = ($Results | ConvertTo-Json -Depth 15) | ||
}) | ||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = ($Results | ConvertTo-Json -Depth 15) | ||
}) | ||
|
||
} | ||
} |
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 +1 @@ | ||
4.7.0 | ||
4.7.1 |