Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining serial number of disk attached to Windows Server 2019

For years I've been using the drive serial number to map virtualized guest disks to the hyper-visor disk. VMWare ESXi for instance will set the disk serial number to the UUID of the disk - allows for easy mapping.

Now that I've got a few Windows Server 2019 servers running I've noticed that none of them are returning the disk Serial Number through the following WMI classes: Win32_DiskDrive, Win32_PhysicalMedia.

I've gone through the documentation for Windows and the WMI classes that I am using but can find no reference to it being deprecated/removed.

How might I get the disk (not the volume) serial number in Windows 2019 using .NET?

like image 351
NTDLS Avatar asked Feb 27 '19 15:02

NTDLS


1 Answers

This issue occurs when the script is unable to read the disk UUID or Serial Number value for one or more virtual machine disks. If the VM is not created with vSphere WebClient, the advanced parameter disk.EnableUUID is not set.

To workaround this issue, set the disk.EnableUUID variable to true.

To configure disk.EnableUUID using the vSphere Web Client:

  • Right-click the virtual machine and click Shut Down Guest OS.
  • Right-dick the virtual machine and click Edit Settings.
  • Click VM Options.
  • Expand the Advanced section and click Edit Configuration.
  • Click Add Row.
  • In the Name column, type disk.EnableUUID.
  • In the Value column, type TRUE.
  • Click OK and click Save.
  • Power on the virtual machine.

Reference: Vmware KB

like image 195
Dev Avatar answered Nov 02 '22 23:11

Dev