1

using command line (powershell, wmic, ...), I would need to know all the info about my internal DVD drive, including what port/socket is connected to, on the motherboard.

is it possible?

I only found something like these:

Get-CimInstance -ClassName Win32_diskdrive

or

wmic cdrom where mediatype!='unknown' get /format:list

but they got me not all the info (especially the socket where it is connected to)

thanks!

3
  • 1
    It is often not possible to reliably determine which physical port a drive is connected to on consumer hardware.
    – Daniel B
    Commented Mar 3, 2022 at 8:15
  • but do you know whether or not a command exists?
    – Ale MaDaMa
    Commented Mar 3, 2022 at 13:44
  • what are you trying to do that requires knowing the port? this seems like a classic x-y problem ... [grin]
    – Lee_Dailey
    Commented Mar 3, 2022 at 21:30

1 Answer 1

1

I answered this here but only for 'Disk Drive' type devices, so I have updated the filters to include CD ROM devices like so:

# query for wmi objects
$drivers = Get-CimInstance win32_pnpsignedDriver -filter 'DeviceName="Disk drive" OR DeviceName="CD-ROM Drive"'
$disks = Get-CimInstance Win32_PnPEntity | ? {$_.service -in 'disk','cdrom' -and $_.name -ne 'Xvd'}  # Xvd is an xbox/windows-store-related device

# Iterate through disks
$result = foreach ($disk in $disks) {
  # disk controllers are usually either IDE (IDE/SATA) or SCSI (NVME/M.2/virtual)
  $controller = Get-CimInstance -query "ASSOCIATORS OF {Win32_PnPEntity.DeviceID='$($disk.DeviceID)'}" | 
    Where {$_.CreationClassName -in 'Win32_IDEController','Win32_SCSIController'}

  # the driver class lists drive location
  $driver = $drivers | where DeviceID -eq $disk.PNPDeviceID

  # combine data for result
  $disk | select Name,
    @{l='location';e={$driver.Location}},
    @{l='controllerName';e={$controller.Name}}
}
$result

On my virtual machine, this outputs the list of hard drive and cd rom devices, and where they are plugged in:

Name                                 location                         controllerName   
----                                 --------                         --------------   
NECVMWar VMware SATA CD00            Bus Number 0, Target Id 0, LUN 0 Standard SATA ...
VMware Virtual disk SCSI Disk Device Bus Number 0, Target Id 0, LUN 0 LSI Adapter, S...
VMware Virtual disk SCSI Disk Device Bus Number 0, Target Id 1, LUN 0 LSI Adapter, S...

Note: Don't assume how many ports there are based on the location numbers

There is no easy way to tell which/how many ports are unused - Windows just does not track them. The best way to get that information is probably going to be looking up your motherboard specs online.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .