# 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 &gt; Custom Fields**, then choose **Import CSV** or **Edit Custom Fields**.

<p class="callout danger">Do not use special characters in Custom Field names.</p>

<p class="callout success">See [Importing and Exporting Custom Field Files](https://kb.filewave.com/books/custom-fields/page/importing-and-exporting-custom-field-files "Importing and Exporting Custom Field Files")</p>

## 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.

<p class="callout danger">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.</p>

<table id="bkmrk-method-prefix-exampl" style="width:100.357143%;"><tbody><tr style="background-color:rgb(251,238,184);"><td style="width:44.094302%;">Method</td><td style="width:17.049918%;">Prefix</td><td style="width:38.855781%;">Example</td></tr><tr><td style="width:44.094302%;">MDM Profile</td><td style="width:17.049918%;">custom\_field</td><td style="width:38.855781%;">%custom\_field.location%</td></tr><tr><td style="width:44.094302%;">Scripted (Launch Argument or Environment Variable)</td><td style="width:17.049918%;">CustomFields</td><td style="width:38.855781%;">%CustomFields.location%</td></tr></tbody></table>

## 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](https://kb.filewave.com/uploads/images/gallery/2023-07/KWMolkJ3wAW80g4q-building-code.png)

![edit custom field values.png](https://kb.filewave.com/uploads/images/gallery/2023-07/JY0sw6vJ1NbUlrYV-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:

- Shell
- Python
- Perl
- Bat
- PowerShell

<p class="callout warning">***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.*</p>

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](https://kb.filewave.com/uploads/images/gallery/2023-07/zMIUsNHb1ZrtwJ1y-edit-custom-field-values-2.png)

![client script.png](https://kb.filewave.com/uploads/images/gallery/2023-07/YCofLXBQSpxIxOPM-client-script.png)![launch arguments.png](https://kb.filewave.com/uploads/images/gallery/2023-07/gPDjvRLqe4qcNDlw-launch-arguments.png)

![environment variables.png](https://kb.filewave.com/uploads/images/gallery/2023-07/dlv3bFRbZSqE4A3P-environment-variables.png)

<p class="callout info">Dates must be ISO-8601 format (for instance: 2011-08-27T23:22:37Z).</p>

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:

- *User:* LDAP entry is matched using either Authusername for iPads or the last LDAP user to log into a macOS and Windows device.
- *Computer:* LDAP entry is found using the device name in inventory against the computer name in the LDAP directory.

![ldap department.png](https://kb.filewave.com/uploads/images/gallery/2023-07/46thyM6csOHOHDir-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](https://kb.filewave.com/uploads/images/gallery/2023-07/m577SwX3la1xhwGU-ldap-active-directory.png)

<p class="callout info">**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.</p>

## 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.

<p class="callout info">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.</p>

![import from csv.png](https://kb.filewave.com/uploads/images/gallery/2023-07/EeVoT1B6jduIeO18-import-from-csv.png)

![import from csv 2.png](https://kb.filewave.com/uploads/images/gallery/2023-07/XnEqcJY3dvUR0oqG-import-from-csv-2.png)

## Related Content

- [Importing and Exporting Custom Field Files](https://kb.filewave.com/books/custom-fields/page/importing-and-exporting-custom-field-files "Importing and Exporting Custom Field Files")

# 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:

```powershell
Get-LocalGroupMember -Group 'Administrators' | Select Name
```

![PowerShell Custom Field example](https://kb.filewave.com/uploads/images/gallery/2023-07/2jiSSC2Xz83wvP0U-client-script-powershell.png)

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.

```bat
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](https://kb.filewave.com/uploads/images/gallery/2023-07/eJ0JAwxTUGTh60LK-client-script-powershell-2.png)

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

```powershell
#############################################################################
# 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
#############################################################################
```

**Related Content**

- [Scripting Languages supported in FileWave](https://kb.filewave.com/books/filewave-general-info/page/scripting-languages-supported-in-filewave)
- [Script Best Practices](https://kb.filewave.com/books/filewave-general-info/page/script-best-practices)

# 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.

<p class="callout danger">Always check a script before deploying to all devices. No, really, always!</p>

## 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](https://kb.filewave.com/books/custom-fields/page/custom-fields "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.

<table id="bkmrk-method-prefix-exampl" style="width:100.357143%;"><tbody><tr style="background-color:rgb(251,238,184);"><td style="width:44.094302%;">Method</td><td style="width:17.049918%;">Prefix</td><td style="width:38.855781%;">Example</td></tr><tr><td style="width:44.094302%;">MDM Profile</td><td style="width:17.049918%;">custom\_field</td><td style="width:38.855781%;">%custom\_field.location%</td></tr><tr><td style="width:44.094302%;">Scripted (Launch Argument or Environment Variable)</td><td style="width:17.049918%;">CustomFields</td><td style="width:38.855781%;">%CustomFields.location%</td></tr></tbody></table>

### 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](https://kb.filewave.com/uploads/images/gallery/2023-07/WFryKBn2v2Tya9Ij-custom-field-exists-error.png)

- **Cancel** - Stops the whole process and makes no changes
- **Skip** - If importing a custom fields file with multiple entries you can skip the one that is conflicting and continue
- **Keep both** - This will add \_2 to the internal name of the field you are importing
- **Overwrite existing** - Replace your existing entry entirely (as long as it isn't used in smart groups, inventory queries, etc)

<p class="callout success">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.</p>

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](https://kb.filewave.com/uploads/images/gallery/2023-07/3D8GVS3GAO20YnjH-internal-name-inuse.png)

# Custom Fields and Multi-Lined Outputs

## Description

[Custom Fields](https://kb.filewave.com/books/custom-fields/page/custom-fields "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.

- What is the best information to return as a value, which can concisely provide meaningful information
- Where is the best place to store the required values for reference

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:

- Return the quantity of 32-bit Apps as an Integer
- Output the list of 32-bit Apps into the FileWave Client log.

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:

- A python section to provide a dated format to match the current log
- A function to define the output if either an Application or Framework has been located (consideration has been made to identify Apps with Apps or within Frameworks, etc)
- A default output for any other identified binary, library, etc
- A command to identify the apps, pushed into a loop to trigger the above
- A total count to report back as the overall integer value

```shell
#!/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 &gt; 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](https://kb.filewave.com/books/filewave-general-info/page/default-tcp-and-udp-port-usage "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](https://kb.filewave.com/uploads/images/gallery/2023-07/T3kRoDLOo8CMQgM0-custom-client-column.png)

<p class="callout info">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.</p>

<p class="callout info">The Select Inventory Fields UI has fewer fields than QueryBuilder because Client View only supports direct 1:1 inventory fields.</p>

<p class="callout danger">Hiding the built-in **IP** column and adding **Inventory: All Devices / IP Address Column** does not change which IP address Client Monitor uses.</p>

## Related Content

- See [Custom Fields](https://kb.filewave.com/books/custom-fields/page/custom-fields "Custom Fields") for more.

# Add FileWave Custom Inventory fields remotely using a Fileset

## Description

<p class="callout info">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](https://kb.filewave.com/books/custom-fields/page/custom-fields "Custom Fields")</p>

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

- FW Central
- A command that outputs needed infrmation
- Basic understanding of scripting

## 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

<table id="bkmrk-string-integer-boole" style="width:102.84%;"><tbody><tr style="background-color:rgb(251,238,184);"><td style="width:24.1316%;">String

</td><td style="width:25.4113%;">Integer

</td><td style="width:22.6691%;">Boolean

</td><td style="width:27.6051%;">DateTime

</td></tr><tr><td style="width:24.1316%;">custom\_string\_01

</td><td style="width:25.4113%;">custom\_integer\_01

</td><td style="width:22.6691%;">custom\_bool\_01

</td><td style="width:27.6051%;">custom\_datetime\_01

</td></tr><tr><td style="width:24.1316%;">custom\_string\_02

</td><td style="width:25.4113%;">custom\_integer\_02

</td><td style="width:22.6691%;">custom\_bool\_02

</td><td style="width:27.6051%;">custom\_datetime\_02

</td></tr><tr><td style="width:24.1316%;">custom\_string\_03

</td><td style="width:25.4113%;">custom\_integer\_03

</td><td style="width:22.6691%;">custom\_bool\_03

</td><td style="width:27.6051%;">custom\_datetime\_03

</td></tr><tr><td style="width:24.1316%;">custom\_string\_04

</td><td style="width:25.4113%;">custom\_integer\_04

</td><td style="width:22.6691%;">custom\_bool\_04

</td><td style="width:27.6051%;">custom\_datetime\_04

</td></tr><tr><td style="width:24.1316%;">custom\_string\_05

</td><td style="width:25.4113%;">custom\_integer\_05

</td><td style="width:22.6691%;">custom\_bool\_05

</td><td style="width:27.6051%;">custom\_datetime\_05

</td></tr><tr><td style="width:24.1316%;">custom\_string\_06

</td><td style="width:25.4113%;">custom\_integer\_06

</td><td style="width:22.6691%;">custom\_bool\_06

</td><td style="width:27.6051%;">custom\_datetime\_06

</td></tr><tr><td style="width:24.1316%;">custom\_string\_07

</td><td style="width:25.4113%;">custom\_integer\_07

</td><td style="width:22.6691%;">custom\_bool\_07

</td><td style="width:27.6051%;">custom\_datetime\_07

</td></tr><tr><td style="width:24.1316%;">custom\_string\_08

</td><td style="width:25.4113%;">custom\_integer\_08

</td><td style="width:22.6691%;">custom\_bool\_08

</td><td style="width:27.6051%;">custom\_datetime\_08

</td></tr><tr><td style="width:24.1316%;">custom\_string\_09

</td><td style="width:25.4113%;">custom\_integer\_09

</td><td style="width:22.6691%;">custom\_bool\_09

</td><td style="width:27.6051%;">custom\_datetime\_09

</td></tr><tr><td style="width:24.1316%;">custom\_string\_10

</td><td style="width:25.4113%;">custom\_integer\_10

</td><td style="width:22.6691%;">custom\_bool\_10

</td><td style="width:27.6051%;">custom\_datetime\_10

</td></tr><tr><td style="width:24.1316%;">custom\_string\_11

</td><td style="width:25.4113%;">custom\_integer\_11

</td><td style="width:22.6691%;">custom\_bool\_11

</td><td style="width:27.6051%;">custom\_datetime\_11

</td></tr><tr><td style="width:24.1316%;">custom\_string\_12

</td><td style="width:25.4113%;">custom\_integer\_12

</td><td style="width:22.6691%;">custom\_bool\_12

</td><td style="width:27.6051%;">custom\_datetime\_12

</td></tr><tr><td style="width:24.1316%;">custom\_string\_13

</td><td style="width:25.4113%;">custom\_integer\_13

</td><td style="width:22.6691%;">custom\_bool\_13

</td><td style="width:27.6051%;">custom\_datetime\_13

</td></tr><tr><td style="width:24.1316%;">custom\_string\_14

</td><td style="width:25.4113%;">custom\_integer\_14

</td><td style="width:22.6691%;">custom\_bool\_14

</td><td style="width:27.6051%;">custom\_datetime\_14

</td></tr><tr><td style="width:24.1316%;">custom\_string\_15

</td><td style="width:25.4113%;">custom\_integer\_15

</td><td style="width:22.6691%;">custom\_bool\_15

</td><td style="width:27.6051%;">custom\_datetime\_15

</td></tr><tr><td style="width:24.1316%;">custom\_string\_16

</td><td style="width:25.4113%;">custom\_integer\_16

</td><td style="width:22.6691%;">custom\_bool\_16

</td><td style="width:27.6051%;">custom\_datetime\_16

</td></tr><tr><td style="width:24.1316%;">custom\_string\_17

</td><td style="width:25.4113%;">custom\_integer\_17

</td><td style="width:22.6691%;">custom\_bool\_17

</td><td style="width:27.6051%;">custom\_datetime\_17

</td></tr><tr><td style="width:24.1316%;">custom\_string\_18

</td><td style="width:25.4113%;">custom\_integer\_18

</td><td style="width:22.6691%;">custom\_bool\_18

</td><td style="width:27.6051%;">custom\_datetime\_18

</td></tr><tr><td style="width:24.1316%;">custom\_string\_19

</td><td style="width:25.4113%;">custom\_integer\_19

</td><td style="width:22.6691%;">custom\_bool\_19

</td><td style="width:27.6051%;">custom\_datetime\_19

</td></tr><tr><td style="width:24.1316%;">custom\_string\_20

</td><td style="width:25.4113%;">custom\_integer\_20

</td><td style="width:22.6691%;">custom\_bool\_20

</td><td style="width:27.6051%;">custom\_datetime\_20

</td></tr></tbody></table>

- Create a fileset with a script where it uses the clients

##### 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
```

- Associate this fileset

<p class="callout info">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</p>

## 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](https://kb.filewave.com/books/filesets-payloads/page/fileset-scripts-overview "Fileset Scripts").

## Useful Commands

- The current logged in user: `stat -f%Su /dev/console`
- The Kernel version: `uname -r`
- Battery Condition: `system_profiler SPPowerDataType | awk '/Condition/ {print $NF}'`
- Current admins: `dscl . read /Groups/admin GroupMembership | cut -d " " -f 2-`

# Example Custom Fields

Some example 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](https://kb.filewave.com/attachments/138).
2. In FileWave Admin, go to **Assistants &gt; Custom Fields &gt; Edit Custom Fields &gt; 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](https://kb.filewave.com/uploads/images/gallery/2023-07/XkD4QOBSsTgFNRCY-embedded-image-ufhh50dc.png)

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

```powershell
$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`:

```shell
#!/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.

## Related articles

- [Custom Fields](https://kb.filewave.com/books/custom-fields/page/custom-fields "Custom Fields")