Parsing WMI Queries
25 March, 2020 at 12:51 am #2712
It has been years since I looked for updates to this fine product and boy was I surprised on how much activity there has been!
I’m still trying to understand the new syntax for the .ini files. One thing that has changed is the OS Version display. It now uses a WMI call. Is there a way to parse the %caption% response so I can pull just the bits I want?
For example namespace:root\cimv2,query:Win32_OperatingSystem,display:%caption% will show
“Microsoft Windows Server 2019 Standard”
Let’s say that I don’t care if it shows Microsoft and want to omit it from the display. Is that possible?
25 March, 2020 at 6:52 am #2715
Not right now.
The thought started the brain ticking over though.
Idea 1: I can imagine a substring tool for example. substr(string,start,length)
Idea 2: A tool that breaks down a string field into words. Your example would produce 5 new fields: %caption_1%, %caption_2% etc. You can then display %caption_3% %caption_4% %caption_5%. You would have to know what the output of the original string field looks like. I’ll have to give implementation some more thought.1+
1 April, 2020 at 7:31 am #2780
This is kind of what I’m looking for but not sure if REGEX can be used in the .ini0
1 April, 2020 at 10:39 pm #2782
Possibly, but I don’t have a good grasp of regex, I’ve tried but it eludes me.0
2 April, 2020 at 8:16 am #2783
Since the OS Version ini option now uses an WMI call, the added “Microsoft” text really messes with my right column mojo.
This PS script really returns what I’m hoping to have
gwmi Win32_OperatingSystem | % Caption | % split ' ' 2 | select -last 1
Oh well, guess I just need to be patient and see what v2.5 will bring. 🙂0
2 April, 2020 at 8:46 am #2784
There you go, problem solved:
CMD=text:Windows,file:powershell.exe,parameters:gwmi Win32_OperatingSystem | % Caption | % split ‘ ‘ 2 | select -last 10
3 April, 2020 at 12:25 am #2785
Oh boy! So close. Now if I can tag on
gwmi Win32_OperatingSystem | % OSArchitecture
at the end, I think life will be good again. 🙂0
4 April, 2020 at 1:24 am #2800
Allow me to explain.
Before we had it show the following:
Windows Server 2019 (64-Bit)
With the cool new CMD feature you showed me, I can get
Windows Server 2019
Can the %OSArchitecture% somehow be appended to the end of the command you sent? Or maybe can “gwmi Win32_OperatingSystem | % OSArchitecture” type code be used on the left column along with a little text?
If not, not a big deal but thought I’d ask. 🙂0
4 April, 2020 at 9:31 am #2802
you use user variables. you have two commands, each sets a user variable. a third command displays the user variables.
CMD=text:Windows,file:powershell.exe,parameters:gwmi Win32_OperatingSystem | % Caption | % split ‘ ‘ 2 | select -last 1,set:win32_os,hidden:1 WMI=namespace:root\cimv2,query:Win32_OperatingSystem,display:%OSArchitecture%,set:win32_arch,hidden:1 text=display:%win32_os% (%win32_arch%)
unfortunately Powershell appends a line feed to it’s output. Your task is to figure out how to strip that trailing line feed from the output.0