Modify/Edit Computer Settings via txt file

I don’t have a handy write-up yet and it would take some time to put it together.

The basic idea is to create a text file with computername[TAB]email mappings. I.E. pasting those two columns from Excel into a text file defaults to tab-delimited text.
Because we are going to send this file to every client, we want to be sure it’s as small as possible. Sending a 10 MB site file to 4,000 clients could generate a lot of traffic. So use Site Files sparingly.

Save the text file, and attach it to a BigFix Custom Site using the “Send to Client” option
image
image

Then you can set up a Task to parse the text file at the client. Now here’s where I messed up my example, I don’t have any clients subscribed to that site in the earlier screenshots, so I repeated attaching the file to my custom site “HCL-Lab-Services-Test” which I’ll use for the rest of this example.

We can find our folder and file in the debugger

q: (name of it, client folder of it) of sites
A: BES Asset Discovery, C:\BES\Client\__BESData\BES Asset Discovery
A: BES Inventory and License, C:\BES\Client\__BESData\BES Inventory and License
A: BES Support, C:\BES\Client\__BESData\BES Support
A: BigFix Labs, C:\BES\Client\__BESData\BigFix Labs
A: BigFix ServiceNow Data Flow, C:\BES\Client\__BESData\BigFix ServiceNow Data Flow
A: CIS Checklist for MS SQL Server 2016, C:\BES\Client\__BESData\CIS Checklist for MS SQL Server 2016
A: CIS Checklist for Windows 2016 MS, C:\BES\Client\__BESData\CIS Checklist for Windows 2016 MS
A: HCL-Lab-Services-Test, C:\BES\Client\__BESData\CustomSite_HCL-2dLab-2dServices-2dTest

q: exists files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")
A: True
T: 2.002 ms
I: singular boolean

q: lines of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")
A: BES-ROOT%09user1@example.com
A: BFC%09user1@example.com
A: BFI%09user1@example.com
A: cent-1.domain.home%09user1@example.com
A: cent-2%09user2@example.com
A: cent-3.domain.home%09user2@example.com
A: DC%09user3@example.com
A: ENDPOINT-1%09user4@example.com

( %09 is the TAB character )

We can find ourselves in the file. Here I’m running on the computer “BES-Root”. I’ll test searching the file for my computer name, and test using the pipe symbol ( | ) to trap an error if my computer name is not present in the file:

q: lines whose (preceding text of first "%09" of it as lowercase = computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")
A: BES-ROOT%09user1@example.com
T: 8.294 ms
I: plural file line

// Test a matching computer
q: (following text of first "%09" of lines whose (preceding text of first "%09" of it as lowercase = computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")) | ""
A: user1@example.com
T: 6.340 ms
I: singular string

// Test a non-matching computer - add an "x" to our computername to test the pipe trapping an error
q: (following text of first "%09" of lines whose (preceding text of first "%09" of it as lowercase = "x" & computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")) | ""
A: 
T: 4.400 ms
I: singular string

// Test that our client setting matches the value in the file
q: not exists setting "Email ID" whose (value of it = (following text of first "%09" of lines whose (preceding text of first "%09" of it as lowercase = computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")) | "") of client
A: True
T: 2.386 ms
I: singular boolean

q: (following text of first "%09" of lines whose (preceding text of first "%09" of it as lowercase = computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")) | ""
A: user1@example.com
T: 2.209 ms
I: singular string

For the Task Relevance, I want to be Relevant if the “Email ID” client setting is not present, or does not match what’s in the site file:

// Test that our client setting matches the value in the file
q: not exists setting "Email ID" whose (value of it = (following text of first "%09" of lines whose (preceding text of first "%09" of it as lowercase = computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")) | "") of client
A: True
T: 2.386 ms
I: singular boolean

For the Task Action, I want to set the “Email ID” client setting to the value I find in the file, or to the empty string “” if my computer name is not found in the file:

setting "Email ID"="{((following text of first "%09" of lines whose (preceding text of first "%09" of it as lowercase = computer name as lowercase) of files "email.txt" of client folders of sites whose (name of it = "HCL-Lab-Services-Test")) | "")}" on "{parameter "action issue date" of action}" for client

3 Likes