View active usb hardware via powershell and Cmd

Rahim CELIK 21 Reputation points
2022-09-20T07:25:43.917+00:00

I can't see the attached usb dongle via cmd and powershell. I need to get serial number with command

I couldn't get it with the following command

import subprocess

print(subprocess.getoutput("C:\Windows\SysWOW64\wbem\wmic.exe diskdrive get model,serialnumber,interfacetype,description"))

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,510 questions
0 comments No comments
{count} votes

Accepted answer
  1. SChalakov 10,381 Reputation points MVP
    2022-09-20T09:20:55.437+00:00

    Hi,

    hm, this is strange. what about this one in command prompt:

    wmic path CIM_USBDevice get PNPDeviceID,USBVersion/format:list   
    

    Does it get it? What is the ouput ogf both PowerShell and cmd command?

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
    Regards
    Stoyan Chalakov


2 additional answers

Sort by: Most helpful
  1. SChalakov 10,381 Reputation points MVP
    2022-09-20T09:04:08.577+00:00

    Hi @Rahim CELIK ,

    what is the exact issue if you use Powershell, do you get an error, what happen exactly?

    gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} | Where-Object {($_.Description -like '*mass*')} | Sort Description,DeviceID | ft Description,DeviceID –auto | Format-Table -AutoSize  
    

    Reference:
    How to retrieve the serial number of a removable drive (PowerShell instructions)
    https://www.adfsolutions.com/knowledge/retrieve-serial-number-removable-drive-powershell-instructions

    Can you please post some more information?

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
    Regards
    Stoyan Chalakov


  2. Rahim CELIK 21 Reputation points
    2022-09-20T09:16:03.277+00:00

    Is there a command where I can get the serial number of the hardware installed on the computer?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.