I have to use Powershell to perform some message tracing. This involves using Start-HistoricalSearch to begin a search, followed by Get-HistoricalSearch to get the results once it's done. Get-HistoricalSearch returns data along these lines:
PS C:\Users\dscally> Get-HistoricalSearch -JobId "e4e8cecd-e943-4d61-b588-6a0a3c8d3cba" | select *RunspaceId : 9b3d4d8f-c257-477e-b4e9-8379c2bf788fJobId : e4e8cecd-e943-4d61-b588-6a0a3c8d3cbaIdentity : e4e8cecd-e943-4d61-b588-6a0a3c8d3cbaSubmitDate : 09/06/2020 13:25:40ReportTitle : First 50 People -90 Days ReceivedStatus : DoneRows : 171069FileRows : 50000ErrorCode :ErrorDescription :FileUrl : < report URL here> ReportStatusDescription : Complete – Ready for downloadReportType : MessageTraceNotifyAddress : {< my email address here >}StartDate : 11/03/2020 14:25:40EndDate : 09/06/2020 14:25:40DeliveryStatus : AllSenderAddress : {}RecipientAddress : {<addresses go here>...}OriginalClientIP :MessageID : {}DLPPolicy : {}TransportRule : {}Locale : en-GBDirection : AllCompletionDate : 09/06/2020 13:47:10EstimatedCompletionTime :JobProgress :EncryptionType :EncryptionTemplate :IsSaved : FalseNumOfBlocks : 0CompressFile : FalseNetworkMessageID : {}Url :
I need to ideally programatically fetch the report linked to by the FileURL property. Unfortunately it's behind a Microsoft SSO authentication page, and I'm struggling to do it other than through the GUI. Is there a way to pass the authentication it needs through Invoke-WebRequest or some other cmdlet so that I can download the reports with a script.
The context is, there's like several hundred of these and that's more manual clicking than I really want to do.