Extracting text from Variable and save it on a file

Hello Experts,

I am fetching some details using powershell using REST APIs and i would like to filter the output from that huge list and save it on a text file.

 

Below is just the part of the script:

 

foreach ($Incident in $Requests.result) {
$output =$Incident | ft description -Wrap | out-string

}
$output | Out-String | Export-Csv -NoTypeInformation -Path C:\Temp\t.txt

 

the t.txt file doesnt contain the value i need. It rather shows below info:

 

“Length”
“536”

 

I need a way to extract information from Description table and save it on a file for further use.

It’s gonna be hard to give reasonable advices how to deal with the input data when you don’t have a clue what the input data looks like. What I can tell from overviewing your code:

Please format your code as code - you may read the first pinned post on top of the list of posts in this forum recommending to read it before posting: Read Me Before Posting! You’ll be Glad You Did!
Please do not use aliasses. They make the code harder to read.
Please use format cmdlets like Format-Table always as the last cmdlet in a pipeline.
If you like to have CSV file you should name it as such and you should use descibing names vor file names and variables.

You may read The Unofficial Powershell Best Practices and Style Guide.

You may post some of the input data as well ( sanitized and formatted as code as well ) if it’s crucial to understand your request.

May I suggest to try the simplest way to deal with this task:

$Requests.result | 
    Export-Csv -Path C:\temp\RestApiFilteredData.csv -NoTypeInformation