@@ -95,7 +95,6 @@ function Get-GraphRequestList {
95
95
$GraphQuery.Query = $ParamCollection.ToString ()
96
96
$PartitionKey = Get-StringHash - String (@ ($Endpoint , $ParamCollection.ToString ()) -join ' -' )
97
97
Write-Information " PK: $PartitionKey "
98
- Write-Information ( ' GET [ {0} ]' -f $GraphQuery.ToString ())
99
98
100
99
# Perform $count check before caching
101
100
$Count = 0
@@ -117,12 +116,27 @@ function Get-GraphRequestList {
117
116
if ($AsApp ) {
118
117
$GraphRequest.asApp = $AsApp
119
118
}
119
+
120
+ if ($Endpoint -match ' %' -or $Parameters.Values -match ' %' ) {
121
+ $TenantId = (Get-Tenants - IncludeErrors | Where-Object { $_.defaultDomainName -eq $TenantFilter -or $_.customerId -eq $TenantFilter }).customerId
122
+ $Endpoint = Get-CIPPTextReplacement - TenantFilter $TenantFilter - Text $Endpoint
123
+ $GraphQuery = [System.UriBuilder ](' https://graph.microsoft.com/{0}/{1}' -f $Version , $Endpoint )
124
+ $ParamCollection = [System.Web.HttpUtility ]::ParseQueryString([String ]::Empty)
125
+ foreach ($Item in ($Parameters.GetEnumerator () | Sort-Object - CaseSensitive - Property Key)) {
126
+ $Value = Get-CIPPTextReplacement - TenantFilter $TenantFilter - Text $Item.Value
127
+ $ParamCollection.Add ($Item.Key , $Value )
128
+ }
129
+ $GraphQuery.Query = $ParamCollection.ToString ()
130
+ $GraphRequest.uri = $GraphQuery.ToString ()
131
+ }
132
+
120
133
if ($Parameters .' $count' -and ! $SkipCache.IsPresent -and ! $NoPagination.IsPresent ) {
121
134
$Count = New-GraphGetRequest @GraphRequest - CountOnly - ErrorAction Stop
122
135
if ($CountOnly.IsPresent ) { return $Count }
123
136
Write-Information " Total results (`$ count): $Count "
124
137
}
125
138
}
139
+ Write-Information ( ' GET [ {0} ]' -f $GraphQuery.ToString ())
126
140
127
141
try {
128
142
if ($QueueId ) {
@@ -153,31 +167,6 @@ function Get-GraphRequestList {
153
167
Write-Information $_.InvocationInfo.PositionMessage
154
168
}
155
169
156
- if ($TenantFilter -ne ' AllTenants' -and $Endpoint -match ' %tenantid%' ) {
157
- Write-Information " Replacing TenantId in endpoint with $TenantFilter "
158
- $TenantId = (Get-Tenants - IncludeErrors | Where-Object { $_.defaultDomainName -eq $TenantFilter -or $_.customerId -eq $TenantFilter }).customerId
159
- $Endpoint = $Endpoint -replace ' %tenantid%' , $TenantId
160
- $GraphQuery = [System.UriBuilder ](' https://graph.microsoft.com/{0}/{1}' -f $Version , $Endpoint )
161
- $ParamCollection = [System.Web.HttpUtility ]::ParseQueryString([String ]::Empty)
162
- foreach ($Item in ($Parameters.GetEnumerator () | Sort-Object - CaseSensitive - Property Key)) {
163
- $ParamCollection.Add ($Item.Key , $Item.Value -replace ' %tenantid%' , $TenantId )
164
- }
165
- $GraphQuery.Query = $ParamCollection.ToString ()
166
- $GraphRequest.uri = $GraphQuery.ToString ()
167
- }
168
-
169
- if ($TenantFilter -ne ' AllTenants' -and $Endpoint -match ' %appid%' ) {
170
- Write-Information " Replacing AppId in endpoint with $env: ApplicationID "
171
- $Endpoint = $Endpoint -replace ' %appid%' , $env: ApplicationID
172
- $GraphQuery = [System.UriBuilder ](' https://graph.microsoft.com/{0}/{1}' -f $Version , $Endpoint )
173
- $ParamCollection = [System.Web.HttpUtility ]::ParseQueryString([String ]::Empty)
174
- foreach ($Item in ($Parameters.GetEnumerator () | Sort-Object - CaseSensitive - Property Key)) {
175
- $ParamCollection.Add ($Item.Key , $Item.Value -replace ' %appid%' , $env: ApplicationID )
176
- }
177
- $GraphQuery.Query = $ParamCollection.ToString ()
178
- $GraphRequest.uri = $GraphQuery.ToString ()
179
- }
180
-
181
170
if (! $Rows ) {
182
171
switch ($TenantFilter ) {
183
172
' AllTenants' {
0 commit comments