[SOLVED] Retrieving the NVMe drive serial number

Share your tips or issues concerning the WAPT Console or WAPT Agent here
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
Julian_
Messages: 17
Registration: July 4, 2025 - 4:21 PM

July 4, 2025 - 4:30 PM

Hello everyone,

this is my first post here because I haven't been able to find a solution myself or on the forum.

I'm looking for a way to retrieve the serial numbers of my workstations via the WAPT agent.
I can't find this information in the software inventory.

I thought I'd do it with a script, but I realized that with NVMe drives, wmic doesn't return the correct information with the command `wmic diskdrive get serialnumber`.

In PowerShell, I tested the command `Get-WmiObject -Class Win32_DiskDrive | Select-Object DeviceID, SerialNumber`, and I get the same result (thankfully, you might say, since it's querying the same database).

However, after some digging, I found the command `Get-PhysicalDisk | Select AdapterSerialNumber`, which gives me the correct information (albeit with a few extra characters).

So my question is: how do I get the result of this PowerShell command to appear in the hardware inventory?
Is it even possible?

Thanks to anyone who knows the answer. :)

Have a good day!
User avatar
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

July 4, 2025 - 4:53 PM

Hello,
There are some serial numbers in the Hardware Inventory tab. Alternatively, you can install the audit-wmi package. Once installed/audited, the information will be visible in the Audit Data tab.
Best regards,
Bertrand
User avatar
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

July 4, 2025 - 5:02 PM

Sorry, AdapterSerialNumber wasn't included in the package. I'll run a quick test and get back to you
User avatar
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

July 4, 2025 - 5:28 PM

We should make this kind of package:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

def install():
    pass

def audit():
    result = run_powershell('Get-PhysicalDisk | Select AdapterSerialNumber',output_format='json')
    WAPT.write_audit_data_if_changed('Physical-Disk','AdapterSerialNumber',result)
    return "OK"
The data will appear in the Audit Data tab
Julian_
Messages: 17
Registration: July 4, 2025 - 4:21 PM

July 7, 2025 - 8:24 AM

Hello,

thank you for the quick reply.
I'll test it today and let you know how it goes.
Julian_
Messages: 17
Registration: July 4, 2025 - 4:21 PM

July 7, 2025 - 09:36

So, I can clearly see a new line in the audit data.
However, the value that appears is "null".

Since the data returned by Get-PhysicalDisk | Select AdapterSerialNumber is not very well formatted, I modified the code slightly as follows:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

def install():
    pass

def audit():

	# Commande pour formater les numéros de série
	powershell_command = '''
	$adapterSerialNumbers = Get-PhysicalDisk | Select-Object -ExpandProperty AdapterSerialNumber
	$modifiedSerialNumbers = $adapterSerialNumbers | ForEach-Object { $_.Substring(0, $_.Length - 5) }
	$modifiedSerialNumbers
	'''
    result = run_powershell(powershell_command,output_format='json')
    WAPT.write_audit_data_if_changed('Physical-Disk','AdapterSerialNumber',result)
    return "OK"
    
In WAPT, the return value is always "null".
I must have made a mistake somewhere, but I can't find it :(
User avatar
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

July 7, 2025 - 11:33

Good morning,
I don't have an AdapterSerialNumber on my machine, but my tests are correct with SerialNumber:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

def install():
    pass

def audit():
    result = run_powershell('Get-PhysicalDisk | Select SerialNumber',output_format='json')
    WAPT.write_audit_data_if_changed('Physical-Disk','SerialNumber',result)
    return "OK"
serialnumber.png
serialnumber.png (21.38 KB) Viewed 13075 times
Julian_
Messages: 17
Registration: July 4, 2025 - 4:21 PM

July 7, 2025 - 1:54 PM

Yes, I can confirm that everything works.
It's just that on my test machine, I didn't have a SerialNumber adapter.

Thanks for the information anyway; I'll look for a way to properly retrieve the disk serial numbers on all models.
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

July 8, 2025 - 09:43

Hi Julien,

thanks for the feedback :-) . I'm marking the topic as resolved.

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked