Is there a way to capture Serial Number from disk drive before imaging the disk
search cancel

Is there a way to capture Serial Number from disk drive before imaging the disk

book

Article ID: 249584

calendar_today

Updated On:

Products

Client Management Suite IT Management Suite Deployment Solution

Issue/Introduction

Is there a way to gather the Serial Number from the Disk Drive before imaging?  We need to know if it is a disk we can image or not, before we wipe the drive.

Resolution

There are a couple of ways to do this.  This is not meant to be a full answer to your question, but enough to get you thinking about how you want to solve this issue.  Use these tools at your disposal.

Option 1:

1) We can run a Client Task (windows script) to run wmic diskdrive get serialnumber.  Save the Output of this Task, and you will have the output in the Console.  User could copy this and manually compare it against your list of serials number to not be wiped.

Create a new Run Script task.  Click Advanced, and choose: Save script output with Task output

Run the Task, and view the results of the command:

2) We capture Physical Disk Serial Number in Inventory on Managed Machines in the Inv_HW_Storage data class, and here's a sample SQL Query to find System Name / Physical Disk info.

NOTE: Inventory is usually captured weekly on all managed systems, and this specific data class (HW_Storage) comes from the Hardware Inventory.  

select c.Name as ComputerName, s.* 
from Inv_HW_Storage s
join vComputer c
on c.Guid = s._ResourceGuid
where c.Name = 'MyComputerName'
OR s.[Serial Number] = 'SomeSerialNumber'

If we assume that a disk never leaves a computer, we could match a computer name to a Disk very easily using the query above.  If drives do get swapped, we could use the WMI command above and do some manual searching for the drive in your list.

One way to put these pieces together, would be to run a SQL Query for the system name I'm imaging, and grab the Physical Disk info (This can be a Run SQL Query on Server Task).  Run the returned data by the List of Disks not to Image.  Then run the WMI command and validate the current Disk matches the Physical Disk info.  If it varies, then look up that SN in the List of Disks not to Image.

Option 2:

1) Run the task below on a system and copy the results to the SMP NSCap Share

wmic diskdrive get serialnumber > serialnumber.txt

copy serialnumber.txt \\SMP\NSCap

2) Run another Task to parse the Text File, query SQL and determine if this system is in the list or not.

@echo off
for /f "skip=1" %%G IN (D:\Program Files\Altiris\Notification Server\NSCap\serialnumber.txt) DO @echo %%G & goto sql
pause


:sql
sqlcmd -S ServerName -U username -P mypassword
use Symantec_CMDB
GO

SELECT c.name, s.[Serial Number]
  FROM Inv_HW_Storage s
  join vComputer c
  on c.Guid = s._ResourceGuid
  WHERE s.[Serial Number] = '%%G'
GO