This is an instruction to find a serial number(S/N) of storage device including hard drive - HDD and SSD, as well as USB flash drive that is connected to a Windows PC. Product serial number is a unique identifier that allows us to look up information about your product and its warranty. Usually, the serial number is labeled on the drive's case. However, it is required that you disassemble your PC to see it. Here we will show how to look for the serial number with built-in Windows 10 tools.
Some businesses require serial numbers for all USB devices attached to their network. The Window Device Manager console displays a list of all your USB peripherals and provides you with detailed specifications. When browsing this detailed information, you can find the serial number of a USB device. Examples of USB devices are flash key, mouse, keyboard and wireless adapter.
wmi get usb device serial number
Click "Start," right-click "Computer" and select "Manage." Select "Device Manager" from the Computer Management console. Alternatively, click the Windows orb and type "device" (without quotes) in the instant search menu. "Device Manager" appears in the list to select.
There are generally two different methods for getting the serial number of a USB-based device... an "easy" way using Windows Management Instrumentation (WMI) and a "hard" way using the Win32 APIs. There are advantages and disadvantages for both methods... one is slow but simple to implement, the other is fast (and potentially provides more information) but is difficult to implement.
OK, now let's do it the "hard" way. The API method uses functions from SetupAPI.DLL for listing devices and getting device parameters. It also uses the normal DeviceIoControl API function from Kernel.DLL to talk to the hardware devices. I'll admit, the technique is a bit convoluted, so let's break it down into steps:
This top-level routine follows the steps outlined above. The FindDiskDevice() function searches the device tree for DeviceNumber that matches that of the drive letter. It returns (via it passed by reference parameters) the full HubDevicePath for the USB Hub and the unique InstanceID of the drive. The GetPortCount() function merely returns the number of USB ports on the Hub. Next it uses the GetDriverKeyName() and FindInstanceIDByKeyName() functions to find the correct port number on the Hub. Next, the GetDeviceDescriptor() method returns the DeviceDescriptor so we know the "index" of the Serial Number string. And lastly, the GetStringDescriptor() function returns the actual serial number string.
Every "Storage Device" is assigned a unique number based upon its device type. We use this feature to allow us to see if two different device paths (such as "\\.\E:" and "\\\\?\\usbstor#disk&ven_lexar&prod_jd_lightning&rev_3000#33000001928000002345&0#53f56307-b6bf-11d0-94f2-00a0c91efb8b") are actually pointing to the same device. Since the STORAGE_DEVICE_NUMBER.DeviceNumber field is only unique with its STORAGE_DEVICE_NUMBER.DeviceType, we "fold" the two numbers together.
Next, we need to find the full "symbolic name" of the USB Hub where are disk is located (an average PC might have 2-3 internal USB hubs), and we also need the "Instance ID" of the device itself (sorta like a device driver name). We start by getting the DeviceNumber of the drive letter assigned to the USB disk. Next, we search the entire "device tree" for a device that matches that device number. After we found a match, we need to "walk the device tree" upwards to get path to the USB Hub. These two strings are passed "by reference", so that we can make changes to them inside this function.
Next we need to get the "Driver Key Name" of a device, given the full path to the USB Hub and the port number on the Hub. The Driver Key Name isn't used directly by this application, instead it's used as an intermediate value to enable us to get the device's Instance ID.
In USB programming, you rarely talk to the USB device directly... you talk to the Hub and ask the Hub to intercede on your behalf. You must know the port number to where the device is located in order to get any meaningful data from the USB Hub. If you don't know the port number, you're forced to try them all to find the one you want.
We need to be able to compare two USB Instance IDs to see if they point to the same device. This is completely analogous to the technique we used to compare storage device numbers. There is no straight-forward technique for a converting a USB "Driver Key Name" into a "Instance ID". So, we're forced to use the SetupAPI again to examine each device in the device tree for a matching DriverKeyName, and when found, we use SetupDiGetDeviceInstanceId() to return the associated InstanceID.
Someone here gave me some help in order to detect if my Yubikey is inserted or not, by checking the Windows system for all "keyboard" devices for the presence of the serial number of my Yubikey. Then once unplugged and found to be missing, take some action like lock the PC.
I doubt WMI can return a serial number for your USB device. About the most it would beable to do is give you the Device ID, which is not what you want.Perhaps the manufacturer has software that can do this job.
Well it was providing the serial number as part of what ever it was. But now it no longer works for the new Yubikeys. I would need to know the new device type and possibly a different thing that contains the serial number in it to check.
Hmm.Some manufacturers embed part or all of the serial number in their device id strings, but this is usually rare.You could get the PNPDeviceID string from Win32_PnPEntity.Or you could get it from the registry with RegRead under:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB
You\u2019re ready to thrive, learn, share, and connect with others. And you\u2019re not alone.", "imageupload.max_uploaded_images_per_upload" : 10, "imageupload.max_uploaded_images_per_user" : 5000, "integratedprofile.connect_mode" : "", "tkb.toc_maximum_heading_level" : "", "tkb.toc_heading_list_style" : "disc", "sharedprofile.show_hovercard_score" : true, "config.search_before_post_scope" : "community", "tkb.toc_heading_indent" : "", "p13n.cta.recommendations_feed_dismissal_timestamp" : -1, "imageupload.max_file_size" : 4000, "layout.show_batch_checkboxes" : false, "integratedprofile.cta_connect_slim_dismissal_timestamp" : -1 }, "isAnonymous" : true, "policies" : "image-upload.process-and-remove-exif-metadata" : false , "registered" : false, "emailRef" : "", "id" : -1, "login" : "Community Alums" }, "Server" : "communityPrefix" : "/community/s/cgfwn76974", "nodeChangeTimeStamp" : 1675900707180, "tapestryPrefix" : "/community", "deviceMode" : "DESKTOP", "responsiveDeviceMode" : "DESKTOP", "membershipChangeTimeStamp" : "0", "version" : "22.12", "branch" : "22.12-release", "showTextKeys" : false , "Config" : "phase" : "prod", "integratedprofile.cta.reprompt.delay" : 30, "profileplus.tracking" : "profileplus.tracking.enable" : false, "profileplus.tracking.click.enable" : false, "profileplus.tracking.impression.enable" : false , "app.revision" : "2302010131-s48b13a6fef-b73", "navigation.manager.community.structure.limit" : "2500" , "Activity" : "Results" : [ ] , "NodeContainer" : "viewHref" : " -p/it-operations-management", "description" : "", "id" : "it-operations-management", "shortTitle" : "IT Operations Management", "title" : "ITOM", "nodeType" : "category" , "Page" : "skins" : [ "servicenow", "theme_hermes", "responsive_peak" ], "authUrls" : "loginUrl" : "/community/s/plugins/common/feature/oidcss/sso_login_redirect/providerid/default?referer=https%3A%2F%2Fwww.servicenow.com%2Fcommunity%2Fitom-forum%2Fdiscover-usb-devices-of-typ-hid-via-wmi-unique-identifier%2Fm-p%2F985494%2Fthread-id%2F77908", "loginUrlNotRegistered" : "/community/s/plugins/common/feature/oidcss/sso_login_redirect/providerid/default?redirectreason=notregistered&referer=https%3A%2F%2Fwww.servicenow.com%2Fcommunity%2Fitom-forum%2Fdiscover-usb-devices-of-typ-hid-via-wmi-unique-identifier%2Fm-p%2F985494%2Fthread-id%2F77908", "loginUrlNotRegisteredDestTpl" : "/community/s/plugins/common/feature/oidcss/sso_login_redirect/providerid/default?redirectreason=notregistered&referer=%7B%7BdestUrl%7D%7D" , "name" : "ForumTopicPage", "rtl" : false, "object" : "viewHref" : "/community/itom-forum/discover-usb-devices-of-typ-hid-via-wmi-unique-identifier/td-p/985494", "subject" : "Discover USB Devices of typ HID via WMI (unique identifier)", "id" : 985494, "page" : "ForumTopicPage", "type" : "Thread" , "WebTracking" : "Activities" : , "path" : "Community:ServiceNow Community/Category:Products/Category:IT Operations Management/Board:ITOM forum/Message:Discover USB Devices of typ HID via WMI (unique identifier)" , "Feedback" : "targeted" : , "Seo" : "markerEscaping" : "pathElement" : "prefix" : "@", "match" : "^[0-9][0-9]$" , "enabled" : false , "TopLevelNode" : "viewHref" : " ", "description" : "", "id" : "cgfwn76974", "shortTitle" : "ServiceNow Community", "title" : "ServiceNow Community", "nodeType" : "Community" , "Community" : "viewHref" : " ", "integratedprofile.lang_code" : "en", "integratedprofile.country_code" : "US", "id" : "cgfwn76974", "shortTitle" : "ServiceNow Community", "title" : "ServiceNow Community" , "CoreNode" : "conversationStyle" : "forum", "viewHref" : " -forum/bd-p/it-operations-management-forum", "settings" : , "description" : "", "id" : "it-operations-management-forum", "shortTitle" : "ITOM forum", "title" : "ITOM forum", "nodeType" : "Board", "ancestors" : [ "viewHref" : " -p/it-operations-management", "description" : "", "id" : "it-operations-management", "shortTitle" : "IT Operations Management", "title" : "ITOM", "nodeType" : "category" , "viewHref" : " -p/product-discussions", "description" : "", "id" : "product-discussions", "shortTitle" : "Products", "title" : "Products", "nodeType" : "category" , "viewHref" : " ", "description" : "", "id" : "cgfwn76974", "shortTitle" : "ServiceNow Community", "title" : "ServiceNow Community", "nodeType" : "Community" ] };LITHIUM.Components.RENDER_URL = '/community/util/componentrenderpage/component-id/#component-id?render_behavior=raw';LITHIUM.Components.ORIGINAL_PAGE_NAME = 'forums/v5/ForumTopicPage';LITHIUM.Components.ORIGINAL_PAGE_ID = 'ForumTopicPage';LITHIUM.Components.ORIGINAL_PAGE_CONTEXT = 'MdJcPsZUDTrRWDdIhq8pv-a9DULhlNqduRBeyGHsb02ZSE8Z6fxoThfbpBYr7ka3PJgQKVLRzFsdiQSM4zyvy-hjH9ghBaGhZvDrKV14TBcpmsobj5zrPuJtYUgiquT6qQMiuNkjPRIeBJWrErTNbTS_RGW0nKw-e65gopsTxIeSzAUQWnFQTds6ifT3lxJi-et8fHKSx_dWrDbzq78ZK35yKpRcDqlpV0Kwlc5TM86I369HKYAOGZnuP7Y1WKz7mHabWLeLm3bO-NPk1eb0K0HGMYC-cbnQRa1lAYbACSMea_4bqF1MDGUzPQ4OtSwllq9HnomWNvMrUffNcD-P6RoDqw701TdMro-FyVmQz6niuB1YaxCUMzCEAcsmfty58aOnpQZflZ_Z1H6XHoov07FOUxbHH8bzGRZNraZSiDrmDQ90837Aq0e1tq1GYbtD';LITHIUM.Css = "BASE_DEFERRED_IMAGE" : "lia-deferred-image", "BASE_BUTTON" : "lia-button", "BASE_SPOILER_CONTAINER" : "lia-spoiler-container", "BASE_TABS_INACTIVE" : "lia-tabs-inactive", "BASE_TABS_ACTIVE" : "lia-tabs-active", "BASE_AJAX_REMOVE_HIGHLIGHT" : "lia-ajax-remove-highlight", "BASE_FEEDBACK_SCROLL_TO" : "lia-feedback-scroll-to", "BASE_FORM_FIELD_VALIDATING" : "lia-form-field-validating", "BASE_FORM_ERROR_TEXT" : "lia-form-error-text", "BASE_FEEDBACK_INLINE_ALERT" : "lia-panel-feedback-inline-alert", "BASE_BUTTON_OVERLAY" : "lia-button-overlay", "BASE_TABS_STANDARD" : "lia-tabs-standard", "BASE_AJAX_INDETERMINATE_LOADER_BAR" : "lia-ajax-indeterminate-loader-bar", "BASE_AJAX_SUCCESS_HIGHLIGHT" : "lia-ajax-success-highlight", "BASE_CONTENT" : "lia-content", "BASE_JS_HIDDEN" : "lia-js-hidden", "BASE_AJAX_LOADER_CONTENT_OVERLAY" : "lia-ajax-loader-content-overlay", "BASE_FORM_FIELD_SUCCESS" : "lia-form-field-success", "BASE_FORM_WARNING_TEXT" : "lia-form-warning-text", "BASE_FORM_FIELDSET_CONTENT_WRAPPER" : "lia-form-fieldset-content-wrapper", "BASE_AJAX_LOADER_OVERLAY_TYPE" : "lia-ajax-overlay-loader", "BASE_FORM_FIELD_ERROR" : "lia-form-field-error", "BASE_SPOILER_CONTENT" : "lia-spoiler-content", "BASE_FORM_SUBMITTING" : "lia-form-submitting", "BASE_EFFECT_HIGHLIGHT_START" : "lia-effect-highlight-start", "BASE_FORM_FIELD_ERROR_NO_FOCUS" : "lia-form-field-error-no-focus", "BASE_EFFECT_HIGHLIGHT_END" : "lia-effect-highlight-end", "BASE_SPOILER_LINK" : "lia-spoiler-link", "FACEBOOK_LOGOUT" : "lia-component-users-action-logout", "BASE_DISABLED" : "lia-link-disabled", "FACEBOOK_SWITCH_USER" : "lia-component-admin-action-switch-user", "BASE_FORM_FIELD_WARNING" : "lia-form-field-warning", "BASE_AJAX_LOADER_FEEDBACK" : "lia-ajax-loader-feedback", "BASE_AJAX_LOADER_OVERLAY" : "lia-ajax-loader-overlay", "BASE_LAZY_LOAD" : "lia-lazy-load";LITHIUM.noConflict = true;LITHIUM.useCheckOnline = false;LITHIUM.RenderedScripts = [ "jquery.ajax-cache-response-1.0.js", "jquery.hoverIntent-r6.js", "InformationBox.js", "InlineMessageReplyEditor.js", "DropDownMenuVisibilityHandler.js", "NoConflict.js", "InlineMessageReplyContainer.js", "Video.js", "ResizeSensor.js", "Globals.js", "jquery.function-utils-1.0.js", "Auth.js", "ThreadedDetailMessageList.js", "prism.js", "Sandbox.js", "json2.js", "jquery.appear-1.1.1.js", "DeferredImages.js", "Text.js", "jquery.css-data-1.0.js", "jquery.ui.core.js", "jquery.scrollTo.js", "ActiveCast3.js", "ProductTagList.js", "Loader.js", "AjaxFeedback.js", "jquery.ui.mouse.js", "jquery.viewport-1.0.js", "EarlyEventCapture.js", "SearchAutoCompleteToggle.js", "Forms.js", "Cache.js", "ElementMethods.js", "jquery.ui.dialog.js", "jquery.ui.position.js", "jquery.js", "LazyLoadComponent.js", "PolyfillsAll.js", "jquery.fileupload.js", "InlineMessageEditor.js", "AutoComplete.js", "jquery.lithium-selector-extensions.js", "DataHandler.js", "PartialRenderProxy.js", "jquery.delayToggle-1.0.js", "jquery.effects.core.js", "Throttle.js", "jquery.blockui.js", "MessageBodyDisplay.js", "jquery.position-toggle-1.0.js", "Tooltip.js", "Link.js", "Lithium.js", "DropDownMenu.js", "jquery.autocomplete.js", "jquery.effects.slide.js", "Placeholder.js", "Components.js", "ElementQueries.js", "jquery.clone-position-1.0.js", "jquery.iframe-shim-1.0.js", "SearchForm.js", "OoyalaPlayer.js", "addthis_widget.js", "HelpIcon.js", "MessageViewDisplay.js", "AjaxSupport.js", "Events.js", "jquery.tmpl-1.1.1.js", "jquery.json-2.6.0.js", "CustomEvent.js", "jquery.ui.widget.js", "ForceLithiumJQuery.js", "SpoilerToggle.js", "jquery.ui.resizable.js", "LiModernizr.js", "jquery.placeholder-2.0.7.js", "jquery.iframe-transport.js", "Namespace.js", "jquery.ui.draggable.js", "jquery.tools.tooltip-1.2.6.js"];(function(){LITHIUM.AngularSupport=function(){function g(a,c)var d,f,b=coreModule:"li.community",coreModuleDeps:[],noConflict:!0,bootstrapElementSelector:".lia-page .min-width .lia-content",bootstrapApp:!0,debugEnabled:!1,useCsp:!0,useNg2:!1,k=function()var a;return function(b)(a=document.createElement("a"));a.href=b;return a.href();LITHIUM.Angular=;return{preventGlobals:LITHIUM.Globals.preventGlobals,restoreGlobals:LITHIUM.Globals.restoreGlobals,init:function(){var a=[],c=document.querySelector(b.bootstrapElementSelector);a.push(b.coreModule);b.customerModules&&0(window.BOOMR_mq=window.BOOMR_mq[]).push(["addVar","rua.upush":"false","rua.cpush":"true","rua.upre":"false","rua.cpre":"false","rua.uprl":"false","rua.cprl":"false","rua.cprf":"false","rua.trans":"SJ-af5d24f2-5110-4d96-8026-ccc1cddc7130","rua.cook":"false","rua.ims":"false","rua.ufprl":"false","rua.cfprl":"false","rua.isuxp":"false","rua.texp":"norulematch"]); !function(a){var e=" -mpulse.net/boomerang/",t="addEventListener";if("True"=="True")a.BOOMR_config=a.BOOMR_config,a.BOOMR_config.PageParams=a.BOOMR_config.PageParams,a.BOOMR_config.PageParams.pci=!0,e=" -mpulse.net/boomerang/";if(window.BOOMR_API_key="RL5JW-PHDQ7-UYYZD-J2FGS-FE4LN",function(){function n(e)a.BOOMR_onload=e&&e.timeStampif(!a.BOOMR!a.BOOMR.version&&!a.BOOMR.snippetExecuted){a.BOOMR=a.BOOMR,a.BOOMR.snippetExecuted=!0;var i,_,o,r=document.createElement("iframe");if(a[t])a[t]("load",n,!1);else if(a.attachEvent)a.attachEvent("onload",n);r.src="javascript:void(0)",r.title="",r.role="presentation",(r.frameElementr).style.cssText="width:0;height:0;border:0;display:none;",o=document.getElementsByTagName("script")[0],o.parentNode.insertBefore(r,o);try_=r.contentWindow.documentcatch(O)i=document.domain,r.src="javascript:var d=document.open();d.domain='"+i+"';void(0);",_=r.contentWindow.document_.open()._l=function()var a=this.createElement("script");if(i)this.domain=i;a.id="boomr-if-as",a.src=e+"RL5JW-PHDQ7-UYYZD-J2FGS-FE4LN",BOOMR_lstart=(new Date).getTime(),this.body.appendChild(a),_.write(" 2ff7e9595c
Comments