Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#673 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Graph Request - Add %tenantid% replace option
  • Loading branch information
JohnDuprey authored Mar 15, 2024
2 parents cfc4ec7 + da3a7ee commit 9f115fe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function Get-GraphRequestList {

$TableName = ('cache{0}' -f ($Endpoint -replace '[^A-Za-z0-9]'))[0..62] -join ''
Write-Host "Table: $TableName"
$Endpoint = $Endpoint -replace '^/', ''
$DisplayName = ($Endpoint -split '/')[0]

if ($QueueNameOverride) {
Expand Down Expand Up @@ -112,6 +113,17 @@ function Get-GraphRequestList {
$QueueReference = '{0}-{1}' -f $TenantFilter, $PartitionKey
$RunningQueue = Get-CippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -ne 'Completed' -and $_.Status -ne 'Failed' }

if ($TenantFilter -ne 'AllTenants' -and $Endpoint -match '%tenantid%') {
$TenantId = (Get-Tenants -IncludeErrors | Where-Object { $_.defaultDomainName -eq $TenantFilter -or $_.customerId -eq $TenantFilter }).customerId
$Endpoint = $Endpoint -replace '%tenantid%', $TenantId
$GraphQuery = [System.UriBuilder]('https://graph.microsoft.com/{0}/{1}' -f $Version, $Endpoint)
$ParamCollection = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
foreach ($Item in ($Parameters.GetEnumerator() | Sort-Object -CaseSensitive -Property Key)) {
$ParamCollection.Add($Item.Key, $Item.Value)
}
$GraphQuery.Query = $ParamCollection.ToString()
}

if (!$Rows) {
switch ($TenantFilter) {
'AllTenants' {
Expand Down

0 comments on commit 9f115fe

Please sign in to comment.