While running cmdlet "Export-LogReportCsv" and setting parameter "StartDateRange" before two weeks (or more),
"The remote server returned an unexpected response: (502) Bad Gateway" error may show as below.
-----------
> Export-LogReportCsv -OutputFile "C:\temp\CitrixConfigLog.csv" -StartDateRange "20XX-XX-21 09:00"
Export-LogReportCsv : The remote server returned an unexpected response: (502) Bad Gateway.
+ CategoryInfo : NotSpecified: (:) [Export-LogReportCsv], ProtocolException
+ FullyQualifiedErrorId : Citrix.XDPowerShell.Status.CommunicationError,Citrix.ConfigurationLogging.Sdk.Commands.ExportLogReportCsvCommand
-----------
And if setting the "StartDateRange" to a nearby DateTime, the issue can be resolved.
Please set the "StartDateRange" to a nearby DateTime.
This is Product Limitation.
When the "StartDateRange" is set before two weeks (or more), executing cmdlet "Export-LogReportCsv" will cause a high site DB load and the query will take too long. As a result, this issue may happen.