Set Variable if NUL...
 
Notifications
Clear all

We appreciate the contributions many of you have been able to make towards repairing the storm damage and keeping a roof over our heads. With your help we’ve been able to complete much of the critical work. There is still work to be done to secure the house and your continued support will be a huge help.

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

[Solved] Set Variable if NULL

6 Posts
3 Users
1 Reactions
2,183 Views
(@thinker)
Active Member Registered
Joined: 2 years ago
Posts: 9
Topic starter   [#612]

I need a little help here, maybe I'm making this complicated but essentially I want to display a tattooed WMI entry if it exists, if it doesn't exist, then a string of text that I've defined.  Otherwise, maybe PowerShell is the way to go?

The goal here is so that IT support can easily determine the device being SCCM built or AutoPilot

 

WMI=set:OSTSName,namespace:root\MYCOMPANY,query:MWP_OSD,display:%TaskSequenceName%,hidden:1
IF=value1:%OSTSName%,value2:null,comparator:eq
set OSTSName2=AutoPilot

TEXT=text:Build Type,display:{{{%OSTSName%}}}{{{%OSTSName2%}}},font-size:100%,color:ffffff

 



   
Nathan_K
(@nathan_k)
Estimable Member Registered
Joined: 6 years ago
Posts: 150
 

I don't think null is a valid value in DTI. It usually replaces a null return with a text value to avoid crashing. The null-result value under the [text] section can define what that should be. Then you'd just need something as simple as the following. You may need value2 to be blank, or matched up to the null-result value.

WMI=set:OSTSName,namespace:root\MYCOMPANY,query:MWP_OSD,display:%TaskSequenceName%,hidden:1
IF=value1:%OSTSName%,value2:,comparator:eq,true:AutoPilot,false:%OSTName%,set:BuildType=%1
TEXT=text:Build Type,display:%BuildType%,font-size:100%,color:ffffff


   
Nathan_K
(@nathan_k)
Estimable Member Registered
Joined: 6 years ago
Posts: 150
 

Also, just reviewing this, it should be "comp", not "comparator".



   
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 2067
 

if the wmi query truly returns a null then DTI will replace it with whatever is in the [text] section as Nathan has advised so that it's got something to put on the screen. Then the IF command would want to compare with that. The default is <null>

I don't have the code handy to check but I suspect both comparator and comp are ok. I notice both appear in the manual. It might have originally been comparator but I got sick of typing that so I added the abbreviated version as well. I've done that in a few places.

 



   
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 2067
 

also check the IF command in the manual for a more compact way of achieving your goal.



   
(@thinker)
Active Member Registered
Joined: 2 years ago
Posts: 9
Topic starter  

Thanks! That did the trick



   
Glenn reacted
Glenn's Page