Custom Fields

Custom Fields

Custom Fields let you create custom inventory values and assign or populate them through administrator values, client scripts, legacy command-line values, LDAP, or CSV import. In FileWave Central, open Assistants > Custom Fields, then choose Import CSV or Edit Custom Fields.

Do not use special characters in Custom Field names.

See Importing and Exporting Custom Field Files

Display Name

The customer-facing name admins see when they work with the Custom Field later.

Internal Name

The system-wide variable name used to reference the Custom Field value.

FileWave can create a Custom Field internal name that matches a built-in inventory item, such as %location%. When you reference custom values, use the prefixes below to avoid collisions with built-in inventory variables.

Method Prefix Example
MDM Profile custom_field %custom_field.location%
Scripted (Launch Argument or Environment Variable) CustomFields %CustomFields.location%

Provided by

This defines where the field comes from and also how it is updated.

Administrator

Use Administrator when admins should set the value directly on selected devices. The value is admin-managed data, so the client does not need to return anything from the device. Assigned to all devices associates the Custom Field with all existing devices and new devices as they enroll. After you choose the Data Type, set a Default Value or enable Restrict Allowed Values. If you restrict allowed values, enter the allowed list and optionally choose a default. To change a device's value later, right-click the device, select Edit Custom Field(s) Value, then double-click the Field Value column and choose a value.

building code.png

edit custom field values.png

Client Script

Client Script sends a script to associated devices and writes the script output as the Custom Field value. You can require exit code 0 before FileWave accepts the output. Client Script Custom Fields support macOS and Windows with these script types:

Important: Python and Perl will need to be installed on your Windows clients. When installing Python and Perl make sure a system path is added to environment variables during install.

The script runs after each verify, before the client sends inventory data.

You can also pass launch arguments and environment variables into scripts, including scripts in desktop Filesets. This lets a script use existing inventory field values as inputs.

edit custom field values 2.png

client script.pnglaunch arguments.png

environment variables.png

Dates must be ISO-8601 format (for instance: 2011-08-27T23:22:37Z).

The last line feed will be ignored to ease conversion, as commands like "echo" (bash) or "print" (python) add a line feed at the end of standard output.  Scripts are stored encrypted on the disk and the FileWave client will automatically decrypt them when it needs to run. The encryption used is RSA 2048 bits, with no symmetric key exchange (only RSA).

Client Command Line

Client Command Line is for legacy Custom Fields that used a script to write to custom.ini on the client. Use Client Script for new Custom Fields. If you previously used custom inventory values in FileWave, those values still appear in the Custom Fields window, and you can rename defaults such as custom_string_01 to clearer names.

LDAP

LDAP Custom Fields pull attribute values from the directory service configured in the LDAP tab of FileWave Preferences. FileWave assigns those values to devices so they can be used in inventory and reporting. Choose the LDAP attribute, such as department, then choose the data type: String, Integer, Boolean, or Date/Time. If the LDAP value does not match the selected data type, FileWave reports a type conversion error. Then choose whether the object class is user or computer:

ldap department.png

How often does LDAP get scanned for updated values?
FileWave scans LDAP when a Custom Field is assigned to a device or when the LDAP server syncs in FileWave Preferences, either manually or at the configured refresh interval. If an LDAP Custom Field is modified, FileWave schedules the directory scan after 120 seconds, which is the minimum delay. To change that delay, contact FileWave Support.

ldap - active directory.png

Other LDAP Considerations:
If the value of the attribute you specified is empty or the attribute is not found in LDAP, then the value of the Custom Field will simply be empty.

In the case of an attribute that has multiple entries, all entries will be returned as encoded JSON array for string custom fields. For other types of custom fields the value would contain the type conversion error flag instead. The order of entries in the JSON array is not specified.

It may happen where no matching LDAP user or computer is found for a given client associated with LDAP custom field(s). In this case, the appropriate status for custom fields values will be set upon extraction ("Matching LDAP User/Computer Not Found"). Administrator has a global option to clear current custom field(s) value when such situation occurs. The option can be found in Preferences, Inventory tab, "Clear value if there is no match between client and LDAP user or computer" checkbox.

Importing from a CSV

Use CSV import to update values for Custom Fields that are already associated with devices. In the Import Custom Fields CSV window, FileWave provides a template where you choose the Custom Fields to include and the device identifier to use. Devices can be identified by FileWave Client Name, Serial Number, Device ID, or FileWave ID.

CSV import updates only Custom Fields already associated with the target devices. If a CSV includes a value for a device that does not already have that Custom Field associated, FileWave skips that value and reports an error.

import from csv.png

import from csv 2.png

Running Built-in PowerShell Commands with Custom Fields

Current FileWave Windows clients are 64-bit, and Windows client-script Custom Fields can run in a 64-bit execution context. In the Custom Field editor, leave On Windows, run as 64-bit enabled when the script uses 64-bit PowerShell modules, 64-bit Windows components, or registry locations that are redirected for 32-bit processes.

Older Custom Fields may still be configured to run as 32-bit after an upgrade. FileWave preserves that setting so existing scripts continue to behave the same way. If an older field, or a field intentionally configured for 32-bit execution, needs to call 64-bit PowerShell, use one of the patterns below.

The example below lists the members of the local Administrators group. For a Custom Field running in the normal 64-bit context, run it directly as a PowerShell script:

Get-LocalGroupMember -Group 'Administrators' | Select Name

PowerShell Custom Field example

If the Custom Field is configured to run in a 32-bit context, some built-in cmdlets and modules may not be available. In that case, create the Custom Field as a BAT script and call the 64-bit executable explicitly. Use the Sysnative path when the command is launched from a 32-bit process on a 64-bit Windows device.

C:\Windows\sysnative\windowsPowerShell\v1.0\powershell.exe "Get-LocalGroupMember -Group 'Administrators' | Select Name"
exit 0

BAT Custom Field using Sysnative to launch 64-bit PowerShell

If an entire PowerShell script needs to relaunch itself from a 32-bit PowerShell process into 64-bit PowerShell, use the following wrapper:

#############################################################################
# If PowerShell is running the 32-bit version on a 64-bit machine, we
# need to force PowerShell to run in 64-bit mode.
#############################################################################
if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
    # write-warning "Take me to 64-bit....."
    if ($myInvocation.Line) {
        &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line
    } else {
        &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args
    }
    exit $lastexitcode
}

# Main script
# Uncomment the next line to prove that we are always in 64-bit
#[Environment]::Is64BitProcess

# Your 64-bit script here.

#############################################################################
# End
#############################################################################

Importing and Exporting Custom Field Files

Starting in FileWave version 13.1 you can import and export custom field definitions. This is ideal for sharing powerful fields not built into standard inventory.

Always check a script before deploying to all devices. No, really, always!

Exporting:

  1. Open your (Assistance → Custom Fields → ) "Edit Custom Fields" UI

  2. Select one or more custom fields

  3. Press "Export" 

  4. Save the "FileWave Custom Fields.customfields" file

  5. Share online, or store for later

Importing:

  1. Download the custom field file

  2. Open your (Assistance → Custom Fields → ) "Edit Custom Fields" UI

  3. Press "import" Browse for file

  4. If the fileset contains a script, verify it is safe for your environment

  5. Associate the field with the needed device(s)

  6. You may also want to import custom field values 

See Custom Fields for more on assigning fields to devices, and importing custom field values.

Conflicts:

Custom vs Internal

FileWave will let you re-use an internal name that is the same as another inventory element.  If a Custom Field were added with an internal name of 'location', two 'location' internal names would co-exist the built-in internal name and the added Custom Field.

A prefix may be added to avoid confusion on matching inventory names.  The prefix varies depending upon the method being used to reference the internal name.

Method Prefix Example
MDM Profile custom_field %custom_field.location%
Scripted (Launch Argument or Environment Variable) CustomFields %CustomFields.location%


Custom vs Custom

If you are importing a custom field with an internal name that is the same as an existing custom field internal name you will see: 

custom field exists error.png

Just because you CAN overwrite an existing custom field doesn't mean that is a good idea. Best practice would be to import it as an additional field and resolve the conflict manually.

If the internal names are in use (Smart Groups, Inventory Queries , DEP auto) when you press "overwrite existing" you will see this telling you where it is in use:

internal_name-inuse.png

Custom Fields and Multi-Lined Outputs

Description

Custom Fields are useful for returning small, reportable values that are not part of standard inventory. When a script finds a long list of results, return a concise value in the Custom Field and store the full list somewhere easier to read.

Information

A scripted Custom Field uses the script output as the inventory value. If the script discovers many items, decide what short value should appear in inventory and where the full output should be stored for review.

For example, macOS 10.15 and later do not run 32-bit apps. A script that returns every 32-bit item as the Custom Field value would be hard to read and search. A better pattern is to return the count as an integer, then store the detailed list in the FileWave Client log.

The required list of 32-bit Apps, though, still needs to be stored, preferably located in an easy to obtain location for analysis.

Details

Continuing with the example, as of macOS 10.15 Apple dropped support for 32-bit Apps.  Consideration was then required for listing 32-bit Apps on devices prior to upgrading to 10.15, such that software upgrades or alternate software could be implemented to replace those utilised.  For this example the chosen options are:

With the count stored as an integer, Inventory Reports (formerly Queries) can target devices with the highest number of 32-bit apps first. As software is replaced, the count should drop until all affected apps have been handled.

The FileWave Client log can be reviewed from FileWave Central. Use a consistent keyword in the script output so the detailed list is easy to find.

The script could look something like the following, which consists of:

#!/bin/zsh

testline=""
linecount=0
logfile=/private/var/log/fwcld.log

function time_formatted {
python - <<END
import datetime

now = datetime.datetime.now()
year = '{:04d}'.format(now.year)
month = '{:02d}'.format(now.month)
day = '{:02d}'.format(now.day)
hour = format(now.hour)
minute = '{:02d}'.format(now.minute)
second = '{:02d}'.format(now.second)
mlsec = format(now.microsecond)
the_time = '{}-{}-{} {}:{}:{}.{}'.format(year, month, day, hour, minute, second, mlsec[:3])

print(the_time)

END
}

function printline {

	if [[ "$@" != "$testline" ]]
	then
		linecount=$(( linecount + 1 ))
		echo -e "\t$linecount: $@"  >> "$logfile"
	fi

	testline="$@"
}

echo $(time_formatted)"|main|INFO|CLIENT|Checking for 32bit apps" >> "$logfile" 

while read line 
do
	case "$line" in

		*".framework"*)
			printline $(echo "$line" | awk -F "\\\.framework" '{print "32bit app|Application|"$1".framework"}')
			;;
		*".app"*)
			printline $(echo "$line" | awk -F "\\\.app" '{print "32bit app|Framework|"$1".app"}')
			;;
		*)
			linecount=$(( linecount + 1 ))
			echo -e "\t$linecount: 32bit app|Other|$line" >> "$logfile"
			;;
	esac
done< <(mdfind "kMDItemExecutableArchitectures == '*i386*' && kMDItemExecutableArchitectures != '*x86*'")

echo $linecount 
echo -e "\tTotal 32bit apps found: $linecount" >> "$logfile"

To view the detailed list, open Client Monitor > Client Log and search for 32bit app. The output may look like this:

Pulling a log via client monitor requires a connection from your admin directly to the client. Client firewall, NAT, and Network ACL might prevent this from happening. Default TCP and UDP Port Usage

2019-07-20 15:46:31.373|main|INFO|CLIENT|Checking for 32bit apps
        1: 32bit app|Framework|/Users/rstehpens/Documents/Papercut MF Clent/mac/legacy/PCClient.app
        2: 32bit app|Framework|/Users/rstehpens/Documents/Papercut MF Clent/mac/legacy/client-local-install.app
        3: 32bit app|Framework|/Applications/BBEdit.app
        4: 32bit app|Framework|/Applications/Adobe Connect/Adobe Connect.app
        5: 32bit app|Framework|/Applications/RingCentral Meetings.app
        6: 32bit app|Application|/System/Library/Frameworks/CoreServices.framework
        7: 32bit app|Application|/System/Library/Frameworks/Carbon.framework
        8: 32bit app|Other|/usr/bin/vmmap32
        9: 32bit app|Other|/usr/bin/stringdups32
        10: 32bit app|Other|/usr/bin/malloc_history32
        11: 32bit app|Other|/usr/bin/leaks32
        12: 32bit app|Other|/usr/bin/heap32
        13: 32bit app|Other|/Users/rstehpens/Desktop/UserData/BigHonkingText
        14: 32bit app|Application|/System/Library/Frameworks/QuickLook.framework
        15: 32bit app|Framework|/System/Library/Input Methods/InkServer.app
        16: 32bit app|Application|/System/Library/Frameworks/DrawSprocket.framework
        17: 32bit app|Application|/System/Library/Frameworks/Scripting.framework
        18: 32bit app|Application|/System/Library/Frameworks/DVComponentGlue.framework
        19: 32bit app|Application|/System/Library/Frameworks/QuickTime.framework
        20: 32bit app|Application|/System/Library/Frameworks/AppKitScripting.framework
        21: 32bit app|Application|/System/Library/Frameworks/DiscRecording.framework
        22: 32bit app|Application|/System/Library/PrivateFrameworks/CoreMediaAuthoring.framework
        23: 32bit app|Application|/System/Library/PrivateFrameworks/vmutils.framework
        24: 32bit app|Application|/System/Library/PrivateFrameworks/CoreMediaPrivate.framework
        25: 32bit app|Application|/System/Library/PrivateFrameworks/CoreMediaIOServicesPrivate.framework
        26: 32bit app|Application|/System/Library/PrivateFrameworks/GraphicsAppSupport.framework
        27: 32bit app|Application|/System/Library/PrivateFrameworks/FWAVCPrivate.framework
        28: 32bit app|Other|/System/Library/Printers/Libraries/libConverter.dylib
        29: 32bit app|Other|/sbin/autodiskmount
        30: 32bit app|Other|/usr/sbin/pictd
        31: 32bit app|Other|/usr/lib/libnetsnmp.5.2.1.dylib
        32: 32bit app|Other|/usr/bin/qtdefaults
        33: 32bit app|Other|/usr/bin/qc2movie
        34: 32bit app|Framework|/usr/local/bin/iHook.app
        35: 32bit app|Other|/Users/rstehpens/Library/Android/sdk/build-tools/28.0.3/mipsel-linux-android-ld
        36: 32bit app|Other|/Users/rstehpens/Library/Android/sdk/build-tools/28.0.3/i686-linux-android-ld
        37: 32bit app|Other|/Users/rstehpens/Library/Android/sdk/build-tools/28.0.3/arm-linux-androideabi-ld
        38: 32bit app|Other|/Users/rstehpens/Library/Android/sdk/tools/mksdcard
        39: 32bit app|Framework|/Library/Application Support/Microsoft/Silverlight/OutOfBrowser/SLLauncher.app
        40: 32bit app|Other|/Users/rstehpens/Scripts/bin/BigHonkingText
        41: 32bit app|Other|/Users/rstehpens/Downloads/Safari/BigHonkingText106
        42: 32bit app|Framework|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/Meeting Center.app
        43: 32bit app|Other|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/libopenh264-0.6.6.0.dylib
        44: 32bit app|Other|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/libcrypto-1.6.2.9.dylib
        45: 32bit app|Other|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/libssl-1.6.2.9.dylib
        46: 32bit app|Framework|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/atmsupload.app
        47: 32bit app|Framework|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/convertpdf.app
        48: 32bit app|Other|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/xml-31.0.0.1.dylib
        49: 32bit app|Other|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/cmcrypto-31.11.0.1.dylib
        50: 32bit app|Framework|/Users/rstehpens/Library/Application Support/WebEx Folder/T31_UMC/asannotation2.app
        Total 32bit apps found: 50

This kind of list is too long for a useful Custom Field value. The count gives you something sortable and reportable, while the log keeps the detailed evidence available.

There are other ways the information could be stored or viewed.  Scripts ran through Filesets, e.g. Activation, Preflight, etc. store the output and may be viewed via Fileset Status.  These scripts have the difference in that they are usually ran just once, which may be better or worse depending upon the use case.  Additionally, scripts can include API calls to alter values in Administration Custom Fields.

Use the same pattern for other scripted Custom Fields: return the small value you need for reporting, and store long supporting output somewhere admins can actually read.

Custom Fields in Client View

Current FileWave versions let you add inventory fields, including custom fields, to Client View.

Steps to add new fields

  1. From Client View, press Customize Columns.
  2. Press Add Inventory Field for advanced inventory options.
  3. Select an inventory field, including a custom field if needed.

Custom_client_column.png

After you add an inventory field, it still appears the next time you open the Select Inventory UI.

If you select a field that is already in Client View, FileWave closes the selector. Open it again and choose a field that has not already been added.

The Select Inventory Fields UI has fewer fields than QueryBuilder because Client View only supports direct 1:1 inventory fields.

Hiding the built-in IP column and adding Inventory: All Devices / IP Address Column does not change which IP address Client Monitor uses.

Add FileWave Custom Inventory fields remotely using a Fileset

Description

Although these forms of Custom Field may still be used, since FileWave 12.7 additional new methods of Custom Fields have been introduced.  The newer form allow for backward compatibility to these older Custom Fields, but provide much greater flexibility and would be recommended.   Details on these may be found here: Custom Fields

Let's say you are using FileWave Integrated Inventory and you want to collect inventory data fields that FileWave does not report yet (you can check if you field is supported in the component list when you edit a query). The solution is to use the custom inventory fields introduced in FileWave version 7.0.0. There are 20 fields for each data type : String, Integer, Boolean, Date. Starting in version 8.5 the FileWave Client can accept input.

You can use this recipe to deploy a Fileset that is able to add the value you want based on a shell command. The script is already written for you and available in the Fileset, you only need to provide the command that outputs the value you want to add.

$ fwcld -custom_write -key <key_name> [-value <value_to_save] [-silent]

Ingredients

Directions

Built-into the FileWave Client is the ability to receive the output of a command and save that to the inventory DB.

  1. Determine what the output of your command is and the best place to save

String

Integer

Boolean

DateTime

custom_string_01

custom_integer_01

custom_bool_01

custom_datetime_01

custom_string_02

custom_integer_02

custom_bool_02

custom_datetime_02

custom_string_03

custom_integer_03

custom_bool_03

custom_datetime_03

custom_string_04

custom_integer_04

custom_bool_04

custom_datetime_04

custom_string_05

custom_integer_05

custom_bool_05

custom_datetime_05

custom_string_06

custom_integer_06

custom_bool_06

custom_datetime_06

custom_string_07

custom_integer_07

custom_bool_07

custom_datetime_07

custom_string_08

custom_integer_08

custom_bool_08

custom_datetime_08

custom_string_09

custom_integer_09

custom_bool_09

custom_datetime_09

custom_string_10

custom_integer_10

custom_bool_10

custom_datetime_10

custom_string_11

custom_integer_11

custom_bool_11

custom_datetime_11

custom_string_12

custom_integer_12

custom_bool_12

custom_datetime_12

custom_string_13

custom_integer_13

custom_bool_13

custom_datetime_13

custom_string_14

custom_integer_14

custom_bool_14

custom_datetime_14

custom_string_15

custom_integer_15

custom_bool_15

custom_datetime_15

custom_string_16

custom_integer_16

custom_bool_16

custom_datetime_16

custom_string_17

custom_integer_17

custom_bool_17

custom_datetime_17

custom_string_18

custom_integer_18

custom_bool_18

custom_datetime_18

custom_string_19

custom_integer_19

custom_bool_19

custom_datetime_19

custom_string_20

custom_integer_20

custom_bool_20

custom_datetime_20

macOS
/usr/local/sbin/FileWave.app/Contents/MacOS/fwcld -custom_write -key FIELD_TO_SAVE_TO -value INFORMATION_TO_SAVE
Windows (FW 15.4.2 and lower)
C:\Program Files (x86)\FileWave\fwcld -custom_write -key FIELD_TO_SAVE_TO -value INFORMATION_TO_SAVE
Windows (FW v15.5.0 or higher)
C:\Program Files\FileWave\client\fwcld -custom_write -key FIELD_TO_SAVE_TO -value INFORMATION_TO_SAVE

Date format may be supplied as either YYYY/MM/DDTHH:MM:SS or YYYY-MM-DDTHH:MM:SS.  E.g 2014/02/20T15:22:43 or 2014-02-20T15:22:43

Examples

Setting "custom_bool_13" to a false:

$ fwcld -custom_write -key custom_bool_13 -value 0
$ fwcld -custom_write -key custom_bool_13 -value false

Setting "custom_bool_13" to true:

$ fwcld -custom_write -key custom_bool_13 -value 1
$ fwcld -custom_write -key custom_bool_13 -value true
$ fwcld -custom_write -key custom_bool_13 -value something

Setting "custom_date_02" to a date:

$ fwcld -custom_write -key custom_date_02 -value 2014-02-20T15:22:43

To remove any key value, just leave off the -value parameter - so to reset the "custom_date_02" value back to it's default.

$ fwcld -custom_write -key custom_date_02 

Example: Saving admins to string 01

#!/bin/sh
# This script is a verification sample
# benm @ fw

now=$(date +"%Y-%m-%d-%H-%M")
echo "$now -- Writing current admins to inventory"

#writes the current administrators to an inventory field
currentadmins=$(dscacheutil -q group -a name admin |grep users)

/usr/local/sbin/FileWave.app/Contents/MacOS/fwcld -custom_write -key custom_string_01 -value "$currentadmins"

Notes

If you set your script to run at the "verification" phase then it will continue to run (default every 24hrs), for more on scripts see: Fileset Scripts.

Useful Commands


Example Custom Fields

Some example fields.

Example Custom Fields

Detecting the Display Model using a Custom Field

Use a FileWave Custom Field to collect the display model reported by Mac and Windows devices. This is useful when you want display information available in inventory, Smart Groups, or device lists without manually checking each computer.

Adding the Custom Field

  1. Download the Custom Field export: Display Model Custom Field.customfields.
  2. In FileWave Admin, go to Assistants > Custom Fields > Edit Custom Fields > Import and import the downloaded file.
  3. Save the changes in the Custom Fields dialog.
  4. Assign the Custom Field to the devices that should report display model information. You can right-click selected devices and choose Edit Custom Field(s) Associations, use a Smart Group to target the field, or enable Assigned to all devices while editing the Custom Field.

Display Model Custom Field configured as a client script

The imported field uses a client script. The Windows section uses PowerShell to read monitor information from ROOT\WMI:

$MonitorList = Get-WmiObject -Class WmiMonitorID -Namespace "ROOT\WMI"
$MonitorOutput = @()
  
foreach ($monitor in $MonitorList) {
$mon = @{}
$manufacturer = $null
$name = $null
  
foreach($ch in $monitor.ManufacturerName) {
if($ch -ne '00') {
$manufacturer += [char]$ch
}
}
  
foreach($ch in $monitor.UserFriendlyName) {
if($ch -ne '00') {
$name += [char]$ch
}
}
$mon = $manufacturer + " " + $name
$MonitorOutput += $mon
}
$MonitorOutput=$MonitorOutput -join ', '
$MonitorOutput
exit 0

The macOS section uses a shell script to read display details from system_profiler:

#!/bin/bash
DisplayModel=`system_profiler SPDisplaysDataType | grep "Resolution:" -B1 | awk -v n=3 'NR%n==1' | sed "s/^[ \t]*//" | sed 's/:/,/g' | tr '\n' ' '`
echo ${DisplayModel}
exit 0

After the field is imported and assigned, save the Custom Fields dialog and allow clients to check in. Devices with more than one attached display may report multiple display models as a comma-separated value.

Results

Once inventory has updated, add the Display Model column to the Clients view, use it in Smart Group criteria, or reference it anywhere Custom Field inventory values are useful.