Brain storming IF ... THEN ... or another way?

I want to set custom properties for a bunch of systems. I have a key field to work from (the Computer Name) and if I’m looking at the right computer name, then I want to set 3 properties that I have values for on hand.

In the task action script, can I’m simply say:

IF (computer name = "computer name value to match") then setting custom_field_1 on {now} for client; setting custom_field_2 on {now} for client; setting custom_field_3 on {now} for client

if so, how to I separate the 3 parts of the action that I want to take?

I have somewhere near 100 systems that I’d like to set these properties for so doing it in an automated fashion is much preferred. Once I get the relevance right I can do some quick text generation in the .csv files that I’m getting the data out of.

1 Like

As usual…it depends :slight_smile:
(these are all untested, use with care)
I wouldn’t want to have to type this out, but you could use an input file to generate an action script to copy/paste into the action, or use the API to “put” the generated fixlet. There are a couple of basic syntaxes that come to mind. Which, if either, of these you should use is an exercise for the reader :slight_smile:

One potential would be

if {computer name as lowercase = "computer1"}
setting "custom_field_1"="custom_value1_computer1" on "{parameter "action issue date" of action}" for client
setting "custom_field_2"="custom_value2_computer1" on "{parameter "action issue date" of action}" for client
endif

if {computer name as lowercase = "computer2"}
setting "custom_field_1"="custom_value2_computer2" on "{parameter "action issue date" of action}" for client
setting "custom_field_2"="custom_value2_computer2" on "{parameter "action issue date" of action}" for client
endif

…etc.

Another could be to create a plural of tuples - where “item 0” is the computername to match, “item 1” is the value for field1, “item 2” is the value for field 2, and each element from the plural acts like a “row”. You want to select the row where item 0 = computername. You’d have to repeat the entire plural tuple for each setting. Note the distinction between “commas” to separate the fields, and “semicolon” to separate the rows -

setting "custom_field_1"="{items 1 of ("computer1","value1Computer1","value2Computer1";"computer2","value1Computer2","value2Computer2") whose (item 0 of it as lowercase = computer name as lowercase)}" on "{parameter "action issue date" of action}" for client

setting "custom_field_2"="{items 2 of ("computer1","value1Computer1","value2Computer1";"computer2","value1Computer2","value2Computer2") whose (item 0 of it as lowercase = computer name as lowercase)}" on "{parameter "action issue date" of action}" for client

I’d probably prefer the second form, as it lends itself a bit better to downloading a configuration file and parsing it at the client. If you had a file formatted as tuple strings (where each “cell” is separated exactly by a comma-space combination)

computer1, value1c1, value2c1
computer2, value1c2, value2c2

you could parse that as something like

setting "custom_field_1"="{tuple string items 1 of lines whose (tuple string item 0 of it as lowercase = computer name as lowercase) of file "my_downloaded_config_file.txt"}" on "{parameter "action issue date" of action}" for client

setting "custom_field_2"="{tuple string items 2 of lines whose (tuple string item 0 of it as lowercase = computer name as lowercase) of file "my_downloaded_config_file.txt"}" on "{parameter "action issue date" of action}" for client

You may find it easier to create a custom registry hive (assuming Windows or a test file otherwise) and then have an analyses read those properties. This will allow more control in both how often you collect the data and being able to easily add new fields.

Regkey example:
[HKEY_LOCAL_MACHINE\SOFTWARE\COMPANY]
“SiteCode”="CA-143"
“Owner-UserID”=“mary”
“Owner-Manager-UserID”=“jowblow”
“City”=“Springfield”
“Country”=“US”
“Region”=“Eastbumble”

Analyses example for one Property evaluating each day:
if exists key "HKLM\SOFTWARE\COMPANY" of native registry and exists value "Region" of key "HKLM\SOFTWARE\COMPANY" of native registry then value "Region" of key "HKLM\SOFTWARE\COMPANY" of native registry as string as uppercase else ""

1 Like

Thanks for the input and possibilities. I’ll explore a little in testing and see what winds up working the best for what I need. Much appreciated!

Following up again…

This is a much more “brute force” and hopefully one time event that I’m manipulating this data around in. In effect, I exported a list of all of the device information for the devices that I want to manipulate these 3 custom fields in. I sent out a spreadsheet to the persons that would know the info that was missing in those fields. They populate that information into a spreadsheet, I’m now taking the data that they returned and “bulk uploading” that data back into BigFix.

In the first example you listed, were you missing a “then” before the setting? (or was it just implied?)

Also, why the use of the { and } braces for the IF test?

Finally, is “action issue date” a variable or was that where you would expect I plugged in the date? (where I was thinking I could simply have used the {now} value)

Lest I forget, though this is a one-time type event, I have to repeat the one-time event for about 1600 devices, broken into multiple groups. So… I’m working on one sub-set now (about 300 devices worth), and eventually get to repeat the same pattern again.

in the end, once I get through the first list, the rest should be easy as I get to drop out some of the parameters that were already set for these devices, or work with shorter lists that I’m only missing 2 of the fields on, versus all 3, etc.

Understood.

The example I gave is in Action Script language, not the Relevance you’d use to check in. The if…endif construct is a little different in ActionScript. This goes in the Action tab of a task, not the Relevance tab.

The curly-brackets are the method to insert a piece of relevance into actionscript.

Parameter "action issue date" of action is indeed a property of the Action (once you take it). It evaluates to the date & time you clicked ‘Take Action’ on the task. Since the client might process actions out-of-order, using this parameter as the Effective Date of the setting ensures that an “old” action does not overwrite the value set in a “newer” action.

If you are not familiar with custom tasks/fixlets, I strongly suggest you read through the Action Authoring Guide. Let me know if that’s the case and we can try to find a link for it.

Also https://developer.bigfix.com is always a good place to start.

1 Like

Thanks again Jason, much appreciated and helps to clarify for me quite a bit.

I have the action that I would need (following your sample) looking something like this:

if {computer name as lowercase = "mycomputer"} setting "_Custom_Location"="Building Room" on "{parameter "action issue date" of action}" for client setting "_Custom_POC"="System Admin" on "{parameter "action issue date" of action}" for client setting "_Custom_Property-Tag"="1234567" on "{parameter "action issue date" of action}" for client end if

I’m using a task that has very simple relevance that checks to see if the computer name starts with the appropriate prefix. From there, I should be able to set all of these params for all of this particular group of systems. I run the task (with many lines like above in the action script) and it never makes any apparent changes to the data that I should be seeing changed, at least not thus far.

Still testing, and hoping to see this work since it would solve a big problem for me in short order, but… still trying to get it nailed down a bit more (and learning quickly along the way).

Looks good to me, but these should be on separate lines…

If …
Setting …
Setting …
Endif

Thanks again @JasonWalker though, hmmm, a final problem it seems…

So… I have something like you had, or so I thought… copied here in a sec… now broken up into separate lines

Seeing an error message indicating unable to parse action script at the “end if” part of the script. Unknown action command. You (me) will need to fix this error before issuing the action.

What I have is exactly this, minus a change to sample data:

if {computer name as lowercase = "mycomputername"}
setting "_Custom_Location"="Location" on "{parameter "action issue date" of action}" for client
setting "_Custom_POC"="System Admin Name" on "{parameter "action issue date" of action}" for client
setting "_Custom_Property-Tag"="Property Tag Number" on "{parameter "action issue date" of action}" for client
end if 

Any thoughts on why it is finding an issue with the Action command?

Oooops, wait, I think I have it. Stupid me (End If, should be Endif)

Final update – IT WORKS/WORKED. Just saw approx. 150 computer’s worth of information updated nicely. Yay. I’ve still gotta rinse and repeat a bit more just because of the sheer volume of systems that I’m going to have to update data for, but even with time copying out of BigFix (copying into a Spreadsheet), manipulating lightly there to add “columns” of commands in front of the values, then copying from there over into Notepad, manipulating to remove extra characters (tabs and such), and then putting into MS Word for a minute so I could easily search and replace and add the appropriate linefeeds / paragraphs / line breaks into things and finally tossing back into notepad one final time to remove formatting before pasting into the action script, it was done!!

Yay, now I’ll use the same basic process again and again to add literally hundreds of devices worth of data on locations, poc’s and/or property tag data into the custom fields in BigFix. From there, it gets copied out into a data warehouse and is there for posterity.

We know that there’s a potential fatal flaw if someone wipes a device and reloads it, and in those cases the System Admin would need to re-populate these fields manually, but at least then we’re working on a single device or at worst a handful of devices to get this data in there.

For those that wonder - the bigger issue I’m trying to solve is a case of systems not talking to each other. Our “Property database” uses a “Property tag” number as it’s key field. BigFix and data warehouse use device names as the key fields and while BigFix has a column where we can populate the Property Tag data, it doesn’t get it by default. We use a naming convention that includes the property tag for most systems, but have a lot of “legacy” systems that don’t have that data there for us to easily retrieve. So, we’re making the system admins provide the fields that are missing – by sending back spreadsheets with the data in them, and then we’re working to automate getting the data into BigFix and eventually into the data warehouse. If the folks above would ever tie these systems together (using something like the device serial number which is in both places) they could easily populate the location information and other information over into the data warehouse.

Fun.

Again, many, many, many thanks! Lots of lessons learned for future usage.

1 Like

Glad this helps with your workflow.

If you can get your admins to place the asset tag in the BIOS we could also read it from there. I also have some location properties based on the Description field of the computer from Active Directory, or the description field in Computer Properties if any of that would be useful.

I’d be interested in seeing the locations pulled from Active Directory Descriptions if you don’t mind sharing. Some of our teams used to use the Description field to stuff that data into.

Our current naming convention requires using the property tag as a suffix of the computer name, and the organization code as the prefix of the name. So it is easy enough to pull the property tag number from the devices that follow that convention. Where it was impossible and a manual effort to resolve was the systems that were simply named any old name (like “dumbledore”, “tolkein”, “nerdville” or others). Those have required manual effort to resolve.

On Dell equipment we can get to the Dell Asset tag and that is typically over in the equipment database somewhere. Or, again, the device serial number is there somewhere. So, my team can do a little database joining work to try to get things together enough to give me back a “property tag of this = this location” type arrangement. From there I can do a little down and dirty massaging to turn that into an action script that will populate the fields that we’d need to populate.

End result eventually will be a fairly well stocked data warehouse full of inventory information that can be used to track who manages a device, where it is location, what the property tag number is, etc. Something that anyone could easily use to audit and determine that we do have a great handle on the equipment that is part of “our” SSP.

Well, time to check another part of this as it seems I’m missing something with another part of the whole puzzle…

Code that looks like this:

if {setting _Custom_Property-Tag of client as string = "1234567"}
setting "_Custom_Location"="Location Data" on "{parameter "action issue date" of action}" for client
endif

Am I in the neighborhood (I think I am, but am apparently missing something as this is so far not working for me…) ?

You’d need to use value of setting "X" of client. Try this…

if {exists setting “_Custom_Property-Tag” whose (value of it as string = “1234567”) of client}
setting “_Custom_Location”=“Location Data” on “{parameter “action issue date” of action}” for client
endif

Thanks again Jason. That took care of getting that part working for me and gives me a great example to follow for future updates like this.

With this, i’m closing in on taking care of most of what I can (hopefully) automate in getting data into my inventory information. I’m closing in on getting the numbers down into the 200 - 300 systems range that need some fields to be populated. Considering that I started with 1600 or so systems that had little or no information regarding location or property tag data, I can easily see the progress.

Now, sadly I get to have fun nagging the System Admin teams to get the missing data to me or directly put it into the system by editing the client configs. Either way, it’ll be nice to get these fixed and thankfully BigFix makes it easy for me to see the data in nice columns as well as making it easy to copy it out of BigFix with column headers and quickly paste over into Excel for more manipulation.

1 Like

Bumping this, since I’m using the same code as previously used, but finding that the changes that I would have expected aren’t getting made for some reason.

I’m using the same code as above, but copied here:

if {computer name as lowercase = "mycomputername"}
setting "_Custom_Location"="Location" on "{parameter "action issue date" of action}" for client
setting "_Custom_POC"="System Admin Name" on "{parameter "action issue date" of action}" for client
setting "_Custom_Property-Tag"="Property Tag Number" on "{parameter "action issue date" of action}" for client
end if 

which I was pretty confident had worked for me before, but which doesn’t seem to be working now, or at least i’m not seeing the changes for the systems that I should be seeing as I spot check my results.

I had about 80 systems worth of changes to get done, and it looks like none of them actually changed from this most recent effort. Argh.

D’oh, yet again, looks like it was a stupid operator error on my part. I’m searching for computer name as lowercase, but the matches that I had it trying to match had uppercase letters within. D’oh!!