Menu

Get a list of ImDisk virtual drives

Dan Winsor
2020-02-11
2020-02-12
  • Dan Winsor

    Dan Winsor - 2020-02-11

    Hi,

    Working in Windows and (preferably) Powershell, I'm looking to return a list of virtual drives supported by ImDisk. When I run:

    imdisk -l

    I get data such as:

    \Device\ImDisk0

    However, I'm looking to get what drive letter that is associated with currently. I'm hoping to avoid looping through all 26 possible drive letters with:

    imdisk -l -m $PossibleDrive

    or the like, but I don't see other options. Can anyone share any ideas? Thanks in advance.

     
  • v77

    v77 - 2020-02-11

    I cannot say for PowerShell, but it's doable with batch:
    for /f %I in ('imdisk -l -n') do @imdisk -l -u %I

    A bit more difficult if you want to keep only the drive letters:
    for /f %I in ('imdisk -l -n') do @for /f "tokens=3 usebackq" %X in (`imdisk -l -u %I 2^>NUL ^|find "Drive letter:"`) do @echo %X

     
  • Dan Winsor

    Dan Winsor - 2020-02-12

    Thanks! While I'm not using your specific script, you did get me over the hump with imdisk -l -n and then imdisk -l u <numbers prior="" from=""> and then split that via PowerShell. Much obliged. </numbers>

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.