Invoke-RestMethod OutFile Empty When PassThru Used Invoke-RestMethod OutFile Empty When PassThru Used powershell powershell

Invoke-RestMethod OutFile Empty When PassThru Used


I believe the -PassThru switch redirects all output to the console only, and I think that is why your file is empty. However, since you have it a variable you could add one more line like so. . .

Write-Output -InputObject $date | Out-File -FilePath "OutFile.txt"