We're planning to build hostnames from hardware serial numbers, but the vendors use different formats and lengths. HP serials are about 10 characters, Dell service tags are 7, and Lenovo serials are 8. Microsoft device serial numbers are usually 12–14 characters, so they exceed our hostname limit once we add a company prefix. We currently have Surface 3 and Surface 4 devices; many of their serials share similar beginnings or endings, but I don't know whether trimming characters from either side is safe or whether there is a documented Microsoft convention. Is there a reliable way to shorten these serial numbers without creating duplicate hostnames?
5 Answers
An asset tag is usually a better naming source than the manufacturer serial number. It can be kept within the hostname limit, works across Dell, HP, Lenovo, and Microsoft hardware, and makes it easier to match the computer to your asset register. You can still store the full serial number in your management or inventory system.
I’d avoid cutting the serial number unless you have a guaranteed uniqueness check. A serial is meant to identify the device as a whole, and the position of the characters may not carry a consistent meaning across models. If you must shorten it, generate the hostname from a controlled inventory system and verify that the shortened value is unique.
If the naming policy allows it, use the full serial number and change the policy instead of modifying the identifier. Otherwise, consider a short site or device prefix plus a generated unique ID, while retaining the complete serial number as a separate inventory attribute.
For Dell systems, the seven-character service tag is commonly used because it is short and designed to identify the device. For the other vendors, I would not assume that the first or last characters of a serial number can safely be discarded; check for collisions against your existing inventory whenever a shortened naming scheme is used.
A MAC address is available on most networked devices and can provide a common format, but it is not ideal as the primary identity because adapters can be replaced, devices can have multiple addresses, and wireless MAC randomization may be enabled. It’s better as a secondary identifier than as the hostname.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures