# Custom Fields

# Custom Fields

Added in FileWave 12.7.0, Custom Fields will allow you to create custom inventory values and assign them to your devices in a 5 different ways. You will find this option under the **Assistants** menu called **Custom Fields**, from there you can either **Import CSV** or **Edit Custom Fields**. The Edit Custom Fields section has four different options you can chose from that will allow you to create custom fields and in turn assign those values to devices.

<p class="callout danger">Important Note: You cannot use special characters in the creation of Custom Fields!</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

A user friendly name for your reference later

## Internal Name

A system-wide variable that can be used in to reference these field values

<p class="callout danger">FileWave will let you create an internal name which is the same as a FileWave inventory item internal name, for example %location% is already a built-in variable. When you are referencing custom values prefix them as below to avoid conflicts.</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

This option will allow you to set a custom field to your selected device(s) with a single or multiple preset values. This will be admin data so nothing has to be sent out to the device themselves. The setting "Assigned to all devices " will auto-associate this custom field to all devices in FileWave and any new devices that become enrolled. After picking the **Data Type**, you can select either a **Default Value** or if you would like to **Restrict Allowed Values**. If "Restrict allowed values" is selected then you can enter as many values as you like and then select one as default. If no value is selected as default then the value will simply be empty for the device. To modify or add these values simply right click on your selected device, select **Edit Custom Field(s) Value**, in the **Field Value** column double click and select the value from your list.

![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 will allow you to create and send out a script to associated devices. The output of this script will be what's written as the value for your custom field. You also have the option to set the output of the script as the custom field value only if the script has the exit code of 0. This option is for both macOS and Windows using the following 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 will be executed after each verify, before sending inventory data.

Another option you have for script, is setting launch arguments and Environment Variables. (This option is also for any scripts you have in Desktop Filesets) So now any inventory field value can be plugged into a script.

![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

This is used for existing Custom Fields that were made prior to FileWave 12.7.0 using a script to write to the custom.ini file on the client, this generally won't be used going forward for new custom fields. But if you have used custom queries with FileWave before, you will notice all of those are still present in the Custom Fields window. This will also allow you to now change the names from the deafult "custom\_string\_01" name for instance, to whatever you like.

### LDAP

You will be able to pull attribute values from whichever directory service is being extracted in the LDAP tab in FileWave Preferences. These values are then assigned to your devices in FileWave so that you can query them at anytime. You will simply find the attribute you would like to query such as "department", which in this case is a String type. Your chooses are String, Integer, Boolean, Date/Time. If the value does not match the data type you will get a type conversion error flag when the value is pulled. Then the object class which is either 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?  
\_Anytime a custom field is assigned to a device in FileWave or when the LDAP server is synced in the FileWave Preferences (this is either at the Refresh interval you can set or manually). However if a LDAP Custom Field is modified, your directory service will not be scanned right away, instead it will be scheduled to scan in 120 seconds; which is the minimum. (to change this time please 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

This will allow you to change values of Custom Fields that have already been associated to devices in bulk. In the Import Custom Fields CSV window we provide a template that will let you choose not only which existing custom fields you would like in the template, but also how you would like to identify devices. Identifying devices in this section can be done with FileWave Client Name, Serial Number, Device ID, or FileWave ID.

<p class="callout info">It is important to remember that the only custom field values that will be changed are ones that have already been associated in FileWave to your devices. If you upload a CSV that specifies a value for a device that does not have the corresponding custom fields associate to it prior to upload, then you will see an error telling you those values were skipped. </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

In FileWave, Windows PowerShell commands run from Custom Fields in a 32-bit context. Some built-in cmdlets require 64-bit PowerShell, so you need to launch the 64-bit executable explicitly.

The example below lists the members of the local Administrators group. If you run it directly as a PowerShell Custom Field, it may fail because FileWave starts it in 32-bit PowerShell.

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

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

To run the command in 64-bit PowerShell, create the Custom Field as a BAT script and call the 64-bit executable first. Use the **Sysnative** path when the command is launched from a 32-bit process on a 64-bit Windows device.

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

![client script powershell 2.png](https://kb.filewave.com/uploads/images/gallery/2023-07/eJ0JAwxTUGTh60LK-client-script-powershell-2.png)

If you need an entire script to relaunch in the native environment, 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)

# 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 an excellent way to provide additional reporting information on devices that are not included as standard inventory. However, there are alternative methods to present this information where the output includes large amounts of text.

## Information

Scripted Custom Fields values are based upon the output of the included script. Although the information desired may be a list of items, sometimes it may be better to return an alternate response to that information and instead store the returned list of items differently. As such, the decision then becomes:

- 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

As an example, consider 32-bit Apps on macOS 10.15 that are no longer supported. The list of responses from such a script could be vast, would be practically unreadable and make searching responses awkward. Instead, consider perhaps counting the amount of Apps stored on a device that are 32-bit and return this as an integer. Devices may then be targeted based upon the amount of 32-bit Apps that are installed.

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.

As an integer, Inventory Queries may be built to target the devices with the highest quantity of installed 32-bit Apps first and over time, as software is replaced, the count should come down, until all apps have been accounted for.

The FileWave Client log is easily accessible from the Admin console. Additionally, by tailoring the output with desired key words, observing this information then becomes easy

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

Viewing the list output to the log file may be achieved via Client Monitor &gt; Client Log and then by searching for '32bit app', which may look something like:

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

As can be seen, this list would be problematic as a returned value in a Custom Field, but the combination of a single response and the easily obtainable list provides a neater solution.

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.

Each required report may have different styles of output, but with some consideration, reporting may be made easier with smarter application.

# Custom Fields in Client View

Starting in FileWave13.3.0 you can add any inventory field to the client view.

## Steps to add new fields

1. From the client view press the "Customize Columns" button
2. Press "Add Inventory Field" for advanced inventory options
3. Select any Inventory field (including custom fields)

![Custom_client_column.png](https://kb.filewave.com/uploads/images/gallery/2023-07/T3kRoDLOo8CMQgM0-custom-client-column.png)

<p class="callout info">When you select an Inventory Field it is not hidden the next time you open the 'Select Inventory UI'  
  
Selecting a field that is already added will just close the UI, you can then open it again and select a field that is not already added.</p>

<p class="callout info">You will notice the fields are limited in the "Select Inventory Fields" UI as compared to the QueryBuilder UI. This is because we are only showing direct 1:1 inventory fields.</p>

<p class="callout danger">Hiding the built-in "IP" column, and adding the Inventory: All Devices / "IP Address Column" does not change that IP 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")