Script to simplify office inventory management

As an office manager, I need to keep inventory, i.e., who uses which screen and laptop. This would be super-simple in theory, if I were always the one who handed over new hardware to employees. For better-or-worse, that doesn’t always happen, because:

Hence, people often need to get the new hardware themselves, either from spares or from the post office.

How do I easy keep track of inventory without having to walk to everyone’s desk?

Broadcast the following script via email or Slack, and ask everyone to send the output.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
sudo echo "Sudo successful"

echo "== START user info =="
echo "Username: $USER"
echo "Fullname: $(getent passwd $USER | cut -d: -f5 | cut -d, -f1)"
echo "== END user info =="

echo "== START laptop info =="
sudo dmidecode -t system | grep 'Manufacturer:'
sudo dmidecode -t system | grep 'Product Name:'
sudo dmidecode -t system | grep 'Serial Number:'
echo "== END laptop info =="

for EDID_FILE in /sys/class/drm/*/edid; do
    echo "== START screen info ==="
    strings ${EDID_FILE} | grep -P "^[a-zA-Z0-9\s]+$"
    echo "== END screen info ==="
done
Hosted with ❤️ by this very website for the sake of privacy. view raw

The output looks as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$ sh ./get-laptop-and-screen-info.sh 
[sudo] password for cklein: 
Sudo successful
== START user info ==
Username: cklein
Fullname: Cristian Klein
== END user info ==
== START laptop info ==
	Manufacturer: Dell Inc.
	Product Name: XPS 13 9310
	Serial Number: 12XXXX3
== END laptop info ==
== START screen info ===
== END screen info ===
== START screen info ===
== END screen info ===
== START screen info ===
== END screen info ===
== START screen info ===
== END screen info ===
== START screen info ===
== END screen info ===
== START screen info ===
== END screen info ===
== START screen info ===
      
HP Z27s
     
XXX1234XXX
== END screen info ===

With this, it’s trivial to compile or check an investory.