Skip to content

Commit aac2684

Browse files
[Feature] add deactivate devices guide (#252)
Co-authored-by: Alan Grgic <[email protected]>
1 parent 4ecf945 commit aac2684

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

docs/guides.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
* [Ingest file events or alerts into a SIEM](userguides/siemexample.md)
66
* [Manage detection list users](userguides/detectionlists.md)
77
* [Manage legal hold users](userguides/legalhold.md)
8+
* [Clean up your environment by deactivating devices](userguides/deactivatedevices.md)
89
* [Write custom extension scripts using the Code42 CLI and py42](userguides/extensions.md)

docs/userguides/deactivatedevices.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Clean up your environment by deactivating devices
2+
3+
Your Code42 environment may contain many old devices that are no
4+
longer active computers and that have not connected to Code42 in
5+
quite some time. In order to clean up your environment, you can
6+
use the CLI to deactivate these devices in bulk.
7+
8+
## Generate a list of devices
9+
10+
You can generate a list of devices using `code42 devices list`. By
11+
default, it will display the list of devices at the command line,
12+
but you can also output it in a number of file formats. For
13+
example, to generate a CSV of devices in your environment, use
14+
this command:
15+
16+
```
17+
code42 devices list -f CSV
18+
```
19+
20+
To save to a file, redirect the output to a file in your shell:
21+
22+
```
23+
code42 devices list -f CSV > output.csv
24+
```
25+
26+
### Filter the list
27+
28+
You can filter or edit the list of devices in your spreadsheet or
29+
text editor of choice, but the CLI has some parameters built in
30+
that can help you to filter the list of devices to just the ones
31+
you want to deactivate. To see a full list of available
32+
parameters, run `code42 devices list -h`.
33+
34+
Here are some useful parameters you may wish to leverage when
35+
curating a list of devices to deactivate:
36+
37+
* `--last-connected-before DATE|TIMESTAMP|SHORT_TIME` - allows you to only see devices that have not connected since a particular date. You can also use a timestamp or short time format, for example `30d`.
38+
* `--exclude-most-recently-connected INTEGER` - allows you to exclude the most recently connected device (per user) from the results. This allows you to ensure that every user is left with at least N device(s), regardless of how recently they have connected.
39+
* `--created-before DATE|TIMESTAMP|SHORT_TIME` - allows you to only see devices created before a particular date.
40+
41+
## Deactivate devices
42+
43+
Once you have a list of devices that you want to remove, you can
44+
run the `code42 devices bulk deactivate` command:
45+
46+
```
47+
code42 devices bulk deactivate list_of_devices.csv
48+
```
49+
50+
The device list must be a file in CSV format containing a `guid`
51+
column with the unique identifier of the devices to be
52+
deactivated. The deactivate command can also accept some optional
53+
parameters:
54+
55+
* `--change-device-name` - prepends `deactivated_<current_date>` to the beginning of the device name, allowing you to have a record of which devices were deactivated by the CLI and when.
56+
* `--purge-date yyyy-MM-dd` - allows you to change the date on which the deactivated devices' archives will be purged from cold storage.
57+
58+
To see a full list of available options, run `code42 devices bulk deactivate -h`.
59+
60+
The `code42 devices bulk deactivate` command will output the guid
61+
of the device to be deactivated, plus a column indicating the
62+
success or failure of the deactivation. To change the format of
63+
this output, use the `-f` or `--format` option.
64+
65+
You can also redirect the output to a file, for example:
66+
67+
```
68+
code42 devices bulk deactivate devices_to_deactivate.csv -f CSV > deactivation_results.csv
69+
```
70+
71+
Deactivation will fail if the user running the command does not
72+
have permission to deactivate the device, or if the user owning
73+
the device is on legal hold.
74+
75+
76+
### Generate the list and deactivate in a single command
77+
78+
You can also pipe the output of `code42 devices list` directly to
79+
`code42 devices bulk deactivate`. When using a pipe, make sure to
80+
use `-` as the input argument for `code42 devices bulk deactivate`
81+
to indicate that it should read from standard input.
82+
83+
Here is an example:
84+
85+
```
86+
code42 devices list \
87+
--last-connected-before 365d \
88+
--exclude-most-recently-connected 1 \
89+
-f CSV \
90+
| code42 devices bulk deactivate - \
91+
-f CSV \
92+
> deactivation_results.csv
93+
```
94+
95+
This lists all devices that have not connected within a year _and_
96+
are not a user's most-recently-connected device, and then attempts
97+
to deactivate them.

0 commit comments

Comments
 (0)