For all the fields and values, starting with "LOAD" and ending with Weight_KGS, I want to create one html table (2 columns: Description & Value/content). But I don't want to hardwire 22 lines of code (x 2)
My array looks as follows: (below is just 1 line)
PS C:\WINDOWS\system32> $Emails
-----------------------------------------
ID : Xtest
Subject : LOAD 85465494557 - TO 37654004
LOAD : 8594557
TransportOrder : 37941004
DeliveryNote :
BusinessCase : Full
ServiceProvider : Me
PickupCountry : FR
Pickup_ID : 2546s
PickupName : YoKo
PickupStreet : Mani 12
PickupZipCode : 25320
PickupCity : Frankfurt
DeliveryName : ManiMani
DeliveryDock : LeftGreen
ReferenceNumber :
ServiceLevel : Prio
TransportMode : FTL
PickupDate : 7/8/2020 00:00:00
PickupTime : 30/12/2020 00:00:00
DeliveryDate : 7/8/2020 00:00:00
DeliveryTime : 30/12/2020 14:34:00
LoadingMeter_mtr : 11.5
Weight_kgs : 2560
Comment_TO : I am new to Powershell
Comment_LOAD : PowershellTest
--------------end data for the first record
For all the fields and values, starting with "LOAD" and ending with Weight_KGS, I want to create one html table (2 columns: Description & Value/content).
I can hardcode the field and the value 22 times: e.g. Write-output "LOAD" $emails.Load but that seems stupid. I am looking for a snippet that for example looks like this:
$startingfield=3
Do while $startingfield<25
$FieldNM = $emails.FieldName[$startingfield]
$FieldVAL = $emails.FieldValue[$startingfield]
Write-output $emails.fieldNM
Write-output $emails.fieldVAL
$startingfield=$startingfield+1
Loop
I apologize as I am new to both writing power-shell scripts and writing questions (I hope someone can help me and point me in the right direction as I have been reading and searching for hours, but I can find the proper search words, ending in the same useless videos)
Many thanks for taking the time to read this far