I am trying to read a line from an ini file. I can identify that the key and section exists, but i need the value after the key “DeviceName”. A sample is shown below. So my result in this example would be “CSBLPT2”. I want to have this as a custom property that I can display in the console when viewing all computers.
Q: key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”
A: CSBLPT2
T: 1.458 ms
So I get the answer i am looking for, and i added this to a new managed property and it works on Win7. How would I modify the relevance to also look in C:\Documents and Settings\All Users\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini for my WinXP? Also, if the file does not exist can the output be “N/A”?
Easiest way might be through some nested if/then/else statements:
//First start with the if/then/else
q: if () then () else ()
E: This expression could not be parsed.
Now create the if and then portion to check if it is Win7 and the file exists
q: if (name of operating system as lowercase contains “win7” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini” ) then (key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (“b”)
A: b
T: 0.050 ms
I: singular string
//Create a nested if/then/else to check if it is xp and the file exists
q: if (name of operating system as lowercase contains “win7” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini” ) then (key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (if () then () else ())
E: This expression could not be parsed.
//put it all together
q: if (name of operating system as lowercase contains “win7” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini” ) then (key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (if (name of operating system as lowercase contains “xp” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) then (key “DeviceName” of section “Telnet” of file “C:\Documents and Settings\All Users\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (“N/A”))
A: N/A
T: 0.071 ms
I: singular string
The statement could be trimmed down with some clever “it” clauses, but this should work.
awesome…it’s the nested part I am still strugling with. Just now doing a POC with BigFix and having this show in our display is just cool. Will help a lot.