Page 1 of 1
[SOLVED] Retrieving the NVMe drive serial number
Published: July 4, 2025 - 4:30 PM
by Julien_
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!
Re: Retrieving the serial number of the NVMe drive
Published: July 4, 2025 - 4:53 PM
by blemoigne
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
Re: Retrieving the serial number of the NVMe drive
Published: July 4, 2025 - 5:02 PM
by blemoigne
Sorry, AdapterSerialNumber wasn't included in the package. I'll run a quick test and get back to you
Re: Retrieving the serial number of the NVMe drive
Published: July 4, 2025 - 5:28 PM
by blemoigne
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
Re: Retrieving the serial number of the NVMe drive
Published: July 7, 2025 - 8:24 AM
by Julien_
Hello,
thank you for the quick reply.
I'll test it today and let you know how it goes.
Re: Retrieving the serial number of the NVMe drive
Published: July 7, 2025 - 9:36 AM
by Julien_
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

Re: Retrieving the serial number of the NVMe drive
Published: July 7, 2025 - 11:33
by blemoigne
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 (21.38 KB) Viewed 13081 times
Re: Retrieving the serial number of the NVMe drive
Published: July 7, 2025 - 1:54 PM
by Julien_
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.
Re: Retrieving the serial number of the NVMe drive
Published: July 8, 2025 - 9:43 AM
by dcardon
Hi Julien,
thanks for the feedback

. I'm marking the topic as resolved.
Denis