@jlpeppers, I’m still thinking this one through, but the following relevance queries:
concatenation “|” of lines whose (it contains “Disk”) of file “C:\Program Files\Dell\SysMgt\idrac\dskserialdump.txt”
concatenation “|” of following texts of firsts "= " of lines whose (it contains “SerialNumber”) of file “C:\Program Files\Dell\SysMgt\idrac\dskserialdump.txt”
Q: (preceding text of first “||” of it, following text of first " = " of following text of first “||” of it) of ((following texts whose (number of substrings “||” of it is 1) of substrings “||” of preceding texts whose (number of substrings “||” of it mod 2 is 0) of substrings “||” of it) of (“||” & (concatenation “||” of (lines of file “C:\Program Files\Dell\SysMgt\idrac\diskserialdump.txt” as string)) & “||”))
A: Disk.Bay.0:Enclosure.Internal.0-1:RAID.Integrated.1-1, XXXXXXXXXXXXX
A: Disk.Bay.1:Enclosure.Internal.0-1:RAID.Integrated.1-1, XXXXXXXXXXXXX
A: Disk.Bay.2:Enclosure.Internal.0-1:RAID.Integrated.1-1, XXXXXXXXXXXXX
This may be inefficient but it works by daisy chaining the next line statements…
((it, following texts of firsts "= " of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next line of next lines of it) of lines starting with “Disk” of file “C:\Program Files\Dell\SysMgt\idrac\dskserialdump.txt”)
If you could give a sample of your “C:\Program Files\Dell\SysMgt\idrac\dskserialdump.txt” file, we might be able to do some parsing tricks for this, even when lines are not in a predictable order.
Here is a sample of the text file. When using BES Reports to export the data it puts the data in a single cell. Is there a way to add a semicolon in between the entries where it can be delimited?
This is the relevance I’m using to parse the text file
if exists file “C:\Program Files\Dell\SysMgt\idrac\dskdump.txt” then ((it, following texts of firsts "= " of next lines of it) of lines starting with “Disk” of file “C:\Program Files\Dell\SysMgt\idrac\dskdump.txt”) else if exists file “C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm\dskdump.txt” then ((it, following texts of firsts "= " of next lines of it) of lines starting with “Disk” of file “C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm\dskdump.txt”) else nothing
Give this one a try to see if it meets your requirement: It should take all the lines and put them together with semicolon between.
if exists file "C:\Program Files\Dell\SysMgt\idrac\dskdump.txt" then (concatenation ";" of (it as string) of (it, following texts of firsts "= " of next lines of it) of lines starting with "Disk" of file "C:\Program Files\Dell\SysMgt\idrac\dskdump.txt") else if exists file "C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm\dskdump.txt" then (concatenation ";" of (it as string) of (it, following texts of firsts "= " of next lines of it) of lines starting with "Disk" of file "C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm\dskdump.txt") else nothing
q: if number of folders ("C:\Program Files\Dell\SysMgt\idrac";"C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm") = 1 then (if (number of files "dskdump.txt" of folders("C:\Program Files\Dell\SysMgt\idrac";"C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm") = 1) then (concatenation ";" of (it as string) of (it, following texts of firsts "= " of next lines of it) of lines starting with "Disk" of files "dskdump.txt" of folders("C:\Program Files\Dell\SysMgt\idrac";"C:\Program Files\Dell\SysMgt\OM_iDRACTools\racadm")) else ("missing or many files")|error "something wrong at file level") else ("missing or multiple folders")|error "something wrong at folder level"
A: Disk.Bay.0:Enclosure.Internal.0-1:RAID.Integrated.1-1, XXXXXXXXXXXXX;Disk.Bay.1:Enclosure.Internal.0-1:RAID.Integrated.1-1, XXXXXXXXXXXXX;Disk.Bay.2:Enclosure.Internal.0-1:RAID.Integrated.1-1, XXXXXXXXXXXXX
The parameters of the file are differing per server meaning the order in which they are listed are not consistent across all servers which gives incorrect information. In this example the server listed in this order below but on another Serialnumber maybe at the top of the list. I’m not having any control how it is written to the text file. How would I be able to extract each parameter correctly?
That is indeed a challenging question – so much so, that we previously had a Challenge on just such a case!
Depending on how this data is being retrieved,it may be easier to change the structure of the data to something more easily parsed, but if you truly have no control over it and cannot get these results from WMI instead, we had four successful approaches on the Challenge at Relevance Challenge December 2019 BONUS: Parsing Paragraphs (answer provided)