@@ -95,7 +95,6 @@ function Get-GraphRequestList {
9595 $GraphQuery.Query = $ParamCollection.ToString ()
9696 $PartitionKey = Get-StringHash - String (@ ($Endpoint , $ParamCollection.ToString ()) -join ' -' )
9797 Write-Information " PK: $PartitionKey "
98- Write-Information ( ' GET [ {0} ]' -f $GraphQuery.ToString ())
9998
10099 # Perform $count check before caching
101100 $Count = 0
@@ -117,12 +116,27 @@ function Get-GraphRequestList {
117116 if ($AsApp ) {
118117 $GraphRequest.asApp = $AsApp
119118 }
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+
120133 if ($Parameters .' $count' -and ! $SkipCache.IsPresent -and ! $NoPagination.IsPresent ) {
121134 $Count = New-GraphGetRequest @GraphRequest - CountOnly - ErrorAction Stop
122135 if ($CountOnly.IsPresent ) { return $Count }
123136 Write-Information " Total results (`$ count): $Count "
124137 }
125138 }
139+ Write-Information ( ' GET [ {0} ]' -f $GraphQuery.ToString ())
126140
127141 try {
128142 if ($QueueId ) {
@@ -153,31 +167,6 @@ function Get-GraphRequestList {
153167 Write-Information $_.InvocationInfo.PositionMessage
154168 }
155169
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-
181170 if (! $Rows ) {
182171 switch ($TenantFilter ) {
183172 ' AllTenants' {
0 commit comments