# Write Legacy Custom Inventory Fields with an fwcld Fileset

## What this legacy recipe does

<p class="callout info">This recipe writes the legacy numbered inventory fields with `fwcld -custom_write`. For new inventory requirements, use [Custom Fields](https://kb.filewave.com/books/custom-fields/page/custom-fields "Custom Fields"), which offer more flexible definitions and reporting. Keep this method where an existing script, report, or integration still depends on the legacy field names.</p>

The legacy schema provides 20 slots for each data type: String, Integer, Boolean, and DateTime. Choose an unused key from the complete matrix below, then make sure the command returns a value that matches that key's data type.

The downloadable Fileset supplies the write script. Configure it with a shell command that prints only the inventory value you want to store:

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

## Requirements

- FileWave Central
- A command that outputs the required inventory value
- Basic scripting knowledge

## Directions

The FileWave Client can capture command output and store it in the selected legacy inventory field.

1. Run the command manually, confirm its output type, and select an unused legacy key from the matrix below.

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