So, I have a powershell script pulling data from an API and returning it as a formatted table, though the final product will be a list. The problem is, when I print the table, I have some entries that I do not want in my final output. Here's how I'm building the table:
Write-Output $xml.pnet_message_history_packet_response.imessage | Format-Table -Property @{Label="form_id"; Expression={$_.formdata.form_id}}
, ... other fields... ,
@{Label="Test"; Expression={$_.formdata.im_field.field_number}}
And here's what the output looks like:
form_id DriverName TrailerNumber TrailerHub DefectFound TractorDefect Field7 TractorDefectD TractorRemarks MoreTractorDef Field11 Field13 TrailerDefect Test
------- ---------- ------------- ---------- ----------- ------------- ------ -------------- -------------- -------------- ------- ------- ------------- ----
125413 {5, 6, 12,...
92477 1
125413 {5, 6, 12,...
52768 regglseton 4022 0 Yes Yes Windows Windows driver side... No Windows Windows {2, 3, 4, ...
52768 Robert F 4035 111 No {2, 3, 4, ...
53420 rs8 {8, 12, 13...
But what I want is to remove all the entries where the form_id is anything BUT 52768. I want to return the same data but only where form_id is 52768. To clarify further, I want the output like this:
form_id DriverName TrailerNumber TrailerHub DefectFound TractorDefect Field7 TractorDefectD TractorRemarks MoreTractorDef Field11 Field13 TrailerDefect Test
------- ---------- ------------- ---------- ----------- ------------- ------ -------------- -------------- -------------- ------- ------- ------------- ----
52768 regglseton 4022 0 Yes Yes Windows Windows driver side... No Windows Windows {2, 3, 4, ...
52768 Robert F 4035 111 No {2, 3, 4, ...
What is the best method to do this? Write the table to a text file and process the file line by line? I was hoping to avoid having to parse another string and was hoping to just narrow down the data printed in the script, but I will of course accept any answer that can help find the best simple solution!
Thank you!
Where-Objectpossible to see ifform_id -eq "52768"?