Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Change a drive letter from Command Prompt or batch script in Windows 8?

I have an external hard drive that I connect often to my computer. At some point it was assigned letter G: and based on that my other software works.

Nowadays, suddenly it gets letter F:

Is there any way I can use a batch script to change the letter from F: to G:. I don't mind running the batch script manually?

If so, what is the code I should use and will it need administrative permissions?

  • command-line

gontadu's user avatar

  • 1 See diskpart and yes you need admin. In theory it should have remembered the drive letter, consider changing it manually on disk management first. –  Bob Jul 28, 2013 at 18:31
  • @Bob: It could be that it only remembers drive letters after they have been assigned manually at least once. –  u1686_grawity Jul 28, 2013 at 19:57
  • 1 Thanks! I have changed it a couple of times manually, but everytime it goes back to the old one. –  gontadu Aug 6, 2013 at 14:42
  • I have noticed that it was remembered when I had one device using a drive letter. When I started using multiple devices with the same drive letter, they get forgot, I have not verified the hypothesis, but I guess Windows 10 remembers the last device assigned to a drive letter. –  BtF Aug 2, 2021 at 8:56

There are several methods:

mountvol – use it once to delete an existing letter, then again to assign a new one;

diskpart – interactive;

diskmgmt.msc aka Disk Management – a graphical tool.

Whichever you choose, assigning once should be enough, the assignment will be remembered afterwards.

u1686_grawity's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged windows windows-8 command-line batch ..

  • The Overflow Blog
  • AI is only as good as the data: Q&A with Satish Jayanthi of Coalesce
  • Tomasz Tunguz: From Java engineer to investor in eight unicorns
  • Featured on Meta
  • Practical effects of the October 2023 layoff
  • Update: New Colors Launched

Hot Network Questions

  • How can I bundle extremely thin wires?
  • How to Append a POINT to a MULTIPOINT column
  • Area of a smooth complex projective curve
  • Why would tuner app confuse C5 with F2?
  • Does Dissociative ego disorder challenge Descartes‘ „cogito-argument“?
  • Who is the 'pale Titan-woman' in Swinburne's 'Ave atque Vale'?
  • Could the Methuselah star be evidence that there was a universe before this one?
  • Short story about a laser-soccer type sport in which a team defends against shots on goal by reflecting the laser beams
  • Shuffled binary numbers
  • How to implement many-to-many relationships without violating design principles in OOP?
  • Would it be possible to work as part-time staff in a university research lab?
  • Can we say "the pot is leaking" or "the pot leaks" when the pot is empty?
  • This build is using a beta version of Xcode and can’t be submitted
  • Why does this Greek Orthodox monastery in Israel fly the English flag?
  • Use of earlier member in designated initializer
  • Who invented file extensions in file names?
  • A dice probability question
  • How to find the width and height of a constrained rectangle? (Precalculus)
  • Why do notes played on bass strings on the highest frets sound bad?
  • how to remove screw deep in a mailbox that has a stripped head
  • How do I determine whether a 5x5 Lights-Out puzzle is solvable without trying to solve it?
  • In DS9, is the 25th hour ever explicitly mentioned?
  • Why multiply a normal?
  • Is "forced expulsion" equivalent to "genocide"?

change drive letter batch

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

How-To Geek

How to change a drive letter on windows 10 or windows 11.

You can change your drive letters in Windows 10 and 11 using the Disk Management utility.

Quick Links

What changing a drive letter does, how to change a drive letter, how to fix programs broken by changing a drive letter.

Changing the letter of a drive is easy on Windows 10 and Windows 11, but you should do it as soon as you add the drive to prevent future hassles. Find out how to change a drive letter here.

Windows assigns drive letters alphabetically --- starting with C --- when they're initialized. If you want to change a drive letter, you should do it before you install anything on the drive. Changing a drive letter after programs are installed could break them since there will be references to an installation location that is no longer there.

Windows has gotten pretty smart about updating shortcuts so that programs work after changing a drive letter. Most of your applications' shortcuts will probably be automatically corrected. Unfortunately, Windows isn't as good about updating file associations. You'll have to manually set the default apps associated with files to fix file associations if they were broken by changing the drive letter.

It is possible to change the boot drive letter to something else, but we don't recommend it. Changing C:\ to another letter is likely to result in severe issues, like a PC that cannot boot into Windows at all. Even if it were able to boot, there would be a huge number of programs that would not be able to run.

Technically speaking, while they are commonly called drive letters, each letter actually refers to a partition on a disk. If you have multiple partitions on a single disk, you will need to assign a letter to each partition to make them all accessible. If a disk has just a single partition, it will just have a single letter pointing to that partition. (However, you do not have to assign a letter to each partition. Partitions without drive letters will not appear in File Explorer and elsewhere.)

Changing a drive letter is pretty simple. Click the Start button, type "Disk Management" in the search bar, and then hit Enter.

The program name displayed in the search will not be Disk Management. It will be "Create and format hard disk partitions."

You could also hit Windows+X or right-click the Start button, and then click "Disk Management."

Identify the drive you'd like to change in the Disk Management Window. In this example, we'll change the letter of the D:\ drive to J:\. You can right-click the drive on the text list, or on the menu below. Either works.

Select "Change Drive Letter and Paths" in the right-click menu that appears.

In the window that pops up, click "Change."

Select whatever letter you want from the drop-down menu. Then click "Ok."

Two popups will warn you about changing your drive letter. Click "Yes" on both of them, and then restart your computer.

Once Windows has restarted, the drive letter should be changed.

There are a few ways you can fix a program broken by changing the drive letter.

Fix The Shortcut

If you're lucky, the only thing that is broken is the shortcut. Fix a shortcut by right-clicking the shortcut on your desktop, and then click Properties.

You need to change the target of the shortcut to the new drive letter.

For example, if GIMP was previously installed at " D :\GIMP 2\bin\gimp-2.10.exe," and you changed the D drive to J, change the target of the shortcut to " J :\GIMP 2\bin\gimp-2.10.exe."

Finalize the change by clicking "Apply" and then "Ok."

Reinstall the Program

Reinstalling the program will generate new entries in the registry, so everything on the computer will know where to look for the program. Some installers won't like reinstalling directly over existing files, so you may need to rename or delete the old installation first.

Change the Drive Letter Back

If you changed the drive letter of a drive with a lot of programs installed, it might be easier to change the drive letter back. Changing the drive letter back should automatically fix any programs and file associations that were broken.

Edit the Registry

You can break programs, or even Windows itself, by editing the registry. Be careful, and learn about how to edit the registry before you try it. Make sure you backup the Windows registry first. You should not attempt this method unless you have no other options.

Windows, and a lot of programs, track where programs are installed via the Windows registry. It is possible to manually adjust the registry to fix broken programs. Keep in mind that there could be dozens of registry entries you need to edit. A program like GIMP can have registry entries for the context menu, for the "Open With" menu, for any file associations, and for the location of its executables. Other programs may only have a few entries related to where it is installed.

If you're not deterred, here's how you do it.

First, you need to know where the program was previously installed. In this case, the program was installed to the "D:\GIMP 2" folder, and the executables were found the "D:\GIMP 2\bin" sub-folder. It is now located at "J:\GIMP 2" instead.

We need to update the registry to reflect the change in location. Click the Start button, type "regedit" into the search bar, right-click Regedit, and click "Run as administrator."

In Regedit, hit Ctrl+F to bring up a search window. Type in the old location for the program you're trying to fix --- "D:\GIMP 2" for our example --- then click "Find Next."

Once Regedit has found something with "D:\GIMP 2" as part of a path, it'll show it to you. Here is an example from the GIMP search.

To actually change them, double click the name of the registry entry you want to modify. Then change the drive letter to J, or whatever you chose. If you didn't otherwise move the folder, leave the rest of the path alone. Then click "Ok."

You'll need to repeat this multiple times. To find the next result using your search term, you can hit the F3 key. There will be a popup once you've found all of the entries.

Changing drive letters can be a simple way to customize your PC. Do it before you install anything on the drive, however. You'll prevent any problems before they occur, and probably save yourself quite a bit of troubleshooting.

Bat file changing the Drive letter depending on the PC.

I'm running into a small issue, I am making a script to join a different domain, but I can't get my head around how to map the drives am planning on using a bat file for this. I just need a replacement for the D so it can be switch between PC's so that the drive letter changes depending on the pc.

My current bat file. (this is still something I'm working on its just the start but I'm missing 1 thing)

@ECHO OFF powershell.exe -ExecutionPolicy Bypass -Command " D: \Domain Join\ PAUSE

User: spicehead-iuf1o

IT Documentation Masterclass

Author Thomas Lee

First, bat files are old school. If you are using modern OSs, I would very strongly suggest using PowerShell.

You can easily run a ChangeDrive.ps1 file on any system (where you have remoting enabled):

Then create a script (Change-Drive.ps1) that does the changing of drive letter.

Something like this:

Of course the 

Author spicehead-iuf1o

I don't need to change the drive I need to run a script that just executes on the pc, but when you plug in a USB on a different pc it may change the drive letter, i need a script that allows the drive letter to change to the pc so I don't have to change the drive letter for each pc. (i need to do this for some 100 pcs)

This topic has been locked by an administrator and is no longer open for commenting.

To continue this discussion, please ask a new question .

Read these next...

Curated Do you use an ad blocker?

Do you use an ad blocker?

Super simple question today for the community. Do you use an ad blocker? If you use an ad blocker or keep up with tech, you might have seen that YouTube is doing their best recently to detect whether or not someone is using ad blockers when accessing thei...

Curated Snap! -- Spaceplane, AI Video Game, Google Math, Genetically-Restored Hearing

Snap! -- Spaceplane, AI Video Game, Google Math, Genetically-Restored Hearing

Your daily dose of tech news, in brief. Welcome to the Snap! Flashback: November 3, 1937: Aiken Approaches IBM About Creating a Giant Brain (Read more HERE.) You need to hear this. Kinsing Actors Exploiting Recent Linux Flaw to Breach ...

Curated Stupid Friday Questions | November 3rd, 2023

Stupid Friday Questions | November 3rd, 2023

What's your favorite aspect(s) of Autumn?(Or most-hated for the less seasonally enthused)What's your PTO strategy for the next 2 months? (Are you that one co-worker that's blocked off every remaining Friday?)What are your thoughts on Extreme Couponing? (B...

Curated Open source backup for Linux environment

Open source backup for Linux environment

HiI am looking for a open source backup software for linux environment compatible both with VM and standalone physical server.Any recommendation would be appreciated.ThanksMohammad

Curated SonicWall TZ600 - reading logs - we got hacked

SonicWall TZ600 - reading logs - we got hacked

Hey guys,Firm i started working with, has a SonicWall TZ600 (about 8yrs old) at an old site, with an average 2 - 5 users at the site.Nothing hosted, no servers, just users and a printer..The Admin password had been left as default :( :( , and was open t...

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

  • 8 contributors

Stores the current directory for use by the popd command, and then changes to the specified directory.

Every time you use the pushd command, a single directory is stored for your use. However, you can store multiple directories by using the pushd command multiple times. The directories are stored sequentially in a virtual stack, so if you use the pushd command once, the directory in which you use the command is placed at the bottom of the stack. If you use the command again, the second directory is placed on top of the first one. The process repeats every time you use the pushd command.

If you use the popd command, the directory on the top of the stack is removed and the current directory is changed to that directory. If you use the popd command again, the next directory on the stack is removed. If command extensions are enabled, the popd command removes any drive-letter assignment created by the pushd command.

If command extensions are enabled, the pushd command accepts either a network path or a local drive letter and path.

If you specify a network path, the pushd command temporarily assigns the highest unused drive letter (starting with Z:) to the specified network resource. The command then changes the current drive and directory to the specified directory on the newly assigned drive. If you use the popd command with command extensions enabled, the popd command removes the drive-letter assignment created by pushd .

To change the current directory from the one in which the batch program was run, and then to change it back:

Related links

Command-Line Syntax Key

popd command

Submit and view feedback for

Additional resources

change drive letter batch

  • Search the community and support articles
  • Search Community member

Ask a new question

JohnBil

Assign Drive Letter by Batch File

I have been having some problems with an external Sata hard drive on my Windows 7 PC. When I reboot, the drive does not maintain its letter. The drive is new, but I also had the same problem with another drive.

If this problem can’t be fixed, I would like to create a batch file to assign the drive a letter quickly and automatically rather than doing it manually through ‘Computer Management’.

Does anyone know the wording, which I should use in the batch file? Any help would be appreciated.

Report abuse

ZigZag3143 (MS -MVP)

Was this reply helpful? Yes No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

Thanks for your feedback.

Replies (1) 

Question info.

  • Norsk Bokmål
  • Ελληνικά
  • Русский
  • עברית
  • العربية
  • ไทย
  • 한국어
  • 中文(简体)
  • 中文(繁體)
  • 日本語

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Batch scripting: iterate over drive letters?

In windows batch scripts, how can I iterate over all drive letters which correspond to physical volumes or mapped shares?

  • drive-letters

kdt's user avatar

7 Answers 7

Also going to suggest a language switch, but to Powershell instead of VBS.

It's the wave of the future...

MattB's user avatar

  • This also yields other drives that don't have anything to do with non-PowerShell things. On my system, Home: is a PSDrive to my home directory, for example. You're getting more back than needed here. –  Joey Apr 18, 2010 at 13:04
  • 1 gwmi win32_logicaldisk | where {$_.DriveType -eq 3} for physical drives, if you want only those with drive letters (possible to not have any mount point, or could be mounted to a folder) add | where {$_.DeviceID -like "*:"} . for network drives just change the original where statement to where {$_DriveType -eq 4} (3 = Local disk, 4 = Network disk). PowerShell is absolutely awesome once you get the hang of these crazy commands. If you list exactly what you're trying to do, I can elaborate more. –  Chris S Apr 18, 2010 at 13:24
  • Another powershell option that doesn't pull back powershell-specific drives: [System.IO.DriveInfo]::GetDrives() –  MattB Apr 19, 2010 at 13:05

Maybe there are better tools now, but there used to be the fsutil command (WinXP).

this returns all the drives in the system.

Dan Andreatta's user avatar

  • 2 Vista: "The FSUTIL utility requires that you have administrative privileges." –  Dennis Williamson Apr 15, 2010 at 13:57

This should work. it creates an array of all drives connected that can be accessed from a for loop. you can do what ever you want with the drives now. i have provided two examples to show how it works.

John Gibbons's user avatar

  • Pierre.Vriens , this uses the 'fsutil fsinfo drives` command to get a list of all drives connected to the computer as their drive letter, then it formats the output to change itself into a math equations that makes it so that for every drive letter it adds one so that it knows how many drives there are. Then it formats the output again to make a string that contains just the drive letters IE "ACDE" if there are four drives connected that are A:\ C:\ D:\ and E:\ then it iterates through that string and makes a variable for every drive letter as !drive%%n! which can be used from a for loop. –  John Gibbons Sep 3, 2018 at 4:21

It's going to be much easier, and far more useful to go with VBScript in that case. http://authors.aspalliance.com/brettb/VBScriptDrivesCollection.asp

sinping's user avatar

  • VBScript is a dead language, I wouldn't recommend anybody learn it if they don't know it already. PowerShell does everything VBScript does, plus more, it's widely supported, and more natural to use (CLI). –  Chris S Apr 18, 2010 at 13:27

You can coax

to be your data source here. Iterating can then be done with standard for /f .

Joey's user avatar

You can try:

for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO @if exist %%i: @echo %%i:

The main limitation with this code is the existance of a CD/DVD drive with no disk. It causes a carp for the user to insert a disk. If you have all CD/DVD drives mapped to Z: you could avoid the carp by removing the final Z in the set.

RobW's user avatar

This works for me from msys, you didn't specify which bash interpreter you are using (the main ones would be msys or cygwin).

davr's user avatar

  • The OP didn't say "bash". –  Dennis Williamson Apr 15, 2010 at 19:53
  • 1 Oh my bad, I misread 'batch' as 'bash'. Well, I'll leave this post here in case someone wants to iterate in bash in windows in the future. –  davr Apr 15, 2010 at 22:07
  • +1 for "I'll leave this post here in case someone wants to iterate in bash in windows in the future" –  mahmoud nezar sarhan Jun 28, 2017 at 6:19

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged windows batch drive-letters ..

  • The Overflow Blog
  • AI is only as good as the data: Q&A with Satish Jayanthi of Coalesce
  • Tomasz Tunguz: From Java engineer to investor in eight unicorns
  • Featured on Meta
  • Practical effects of the October 2023 layoff
  • Update: New Colors Launched

Hot Network Questions

  • Can a computer by guilty of insider trading?
  • Does this 1978 code for a 6800 really clear ALL of memory?
  • On Giuga numbers
  • How to implement many-to-many relationships without violating design principles in OOP?
  • Can we say "the pot is leaking" or "the pot leaks" when the pot is empty?
  • What happens if a DNS record points to non-controlled IP address?
  • Can human body heat cause a mobile phone's battery to "run down at a faster rate"?
  • Is it illegal to warm up your car?
  • What would it take for a space craft to travel to the sun's nadir and stop?
  • Is there a tailwind limit while in cruise?
  • How long should I keep minced garlic in lemon juice?
  • What was the purpose of Tartan's "disable" statement?
  • Can two songs share the same melodic notes but still have distinct melodies?
  • Why do some websites require logging in twice? Not two steps, but two full username/password entries
  • In DS9, is the 25th hour ever explicitly mentioned?
  • Could the Methuselah star be evidence that there was a universe before this one?
  • How to use Compile to optimize the performance of a function calculating the distance between two points?
  • Is "forced expulsion" equivalent to "genocide"?
  • Who is the 'pale Titan-woman' in Swinburne's 'Ave atque Vale'?
  • How do I determine whether a 5x5 Lights-Out puzzle is solvable without trying to solve it?
  • Is this brake mounted incorrectly?
  • Should we encourage our 2-year old to give up his naps?
  • Do these all have the same meaning? "I'd rather you stayed/stay/should stay"
  • Why have more countries cut the diplomatic ties with Israel than with Russia?

change drive letter batch

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

IMAGES

  1. How to Change Drive Letter in Windows 10 (Easy to Follow Guide)

    change drive letter batch

  2. How to Change Drive Letter with CMD Windows 10

    change drive letter batch

  3. Formatting Hard Drives and Changing Drive Letters in Windows 10

    change drive letter batch

  4. 2 Easy Ways to Add, Remove or Change A Drive Letter in Windows 10

    change drive letter batch

  5. How to Change/Rename/Assign Drive Letter in CMD Windows 10/7

    change drive letter batch

  6. How to change Drive letter in Windows 11/10

    change drive letter batch

COMMENTS

  1. windows

    If you run the .BAT file from the USB drive you don't need to specify the drive letter, only the path and/or file relative to the .BAT file. Example: If Unzip.BAT is in the root of the USB Drive and the .zip is in a folder called "classified docs" under a folder called "secret" it would be \secret\classified docs\

  2. Batch File Assign Drive Letter

    It's better just to leave the drive letter as-is and mount the drive to another drive instead. You can use subst in a batch file instead (which can run by any users) and mount the drive that contains that batch file. @echo off cls echo Drive Letter Change Tool echo. echo Please Enter The Letter You Wish To Assign set /P "NewLetter=Please Enter ...

  3. Change Directory in Windows Batch Script

    Change to Drive Letter. To change to a specific drive letter while the command prompt directory is using a different drive letter than the one you need to change to, simply use the /D parameter with the CD command (e.g. CD /D <DriveLetter>:) to change to a different drive letter before running proceeding commands.

  4. Drive letter of given file in windows batch

    I want to get the Drive letter of the file. Example: myScript.bat C:\exampleFolder\somefile.txt D:\someOtherFolder\differentfile.txt ... %~s1 Change the meaning of f, n, s and x to reference the Short 8.3 name (if it exists.) ... parameters - A command line argument (or parameter) is any value passed into a batch script. Share. Improve this answer.

  5. batch

    There you can change the drive letter that's assigned to the drive. After this is done, whenever the drive is plugged back in, ... Create your batch file scripts using %~d0 as the drive letter and colon. %~d0 is replaced by the drive containing the script. So if on one machine the thumb drive is F %~d0 is equivalent to F: On another machine the ...

  6. Change a drive letter from Command Prompt or batch script in Windows 8

    1 Answer. Sorted by: 3. There are several methods: mountvol - use it once to delete an existing letter, then again to assign a new one; diskpart - interactive; diskmgmt.msc aka Disk Management - a graphical tool. Whichever you choose, assigning once should be enough, the assignment will be remembered afterwards.

  7. assign

    You can also use this command to change the drive letter associated with a removable drive. If no drive letter or mount point is specified, the next available drive letter is assigned. ... You can't assign drive letters to system volumes, boot volumes, or volumes that contain the paging file. In addition, you cannot assign a drive letter to an ...

  8. How to Change a Drive Letter on Windows 10 or Windows 11

    Changing a drive letter is pretty simple. Click the Start button, type "Disk Management" in the search bar, and then hit Enter. The program name displayed in the search will not be Disk Management. It will be "Create and format hard disk partitions." You could also hit Windows+X or right-click the Start button, and then click "Disk Management."

  9. Batch file help with changing drive letter

    If so the way to call them is. The %0\..\ syntax will set the folder to be the folder the batch file is executing from. Using this syntax will eliminate the need to change drives or directories. Ok, I've made those changes, and modified the scripts (example below) you see called above.

  10. Change a drive letter

    The following steps show how to change the drive letter. Open Disk Management with administrator permissions. In Disk Management, select and hold (or right-click) the volume on which you want to change or add a drive letter and select Change Drive Letter and Paths. Tip. If you don't see the Change Drive Letter and Paths option or it's grayed ...

  11. Bat file changing the Drive letter depending on the PC

    I don't need to change the drive I need to run a script that just executes on the pc, but when you plug in a USB on a different pc it may change the drive letter, i need a script that allows the drive letter to change to the pc so I don't have to change the drive letter for each pc. (i need to do this for some 100 pcs)

  12. pushd

    If you specify a network path, the pushd command temporarily assigns the highest unused drive letter (starting with Z:) to the specified network resource. The command then changes the current drive and directory to the specified directory on the newly assigned drive. If you use the popd command with command extensions enabled, the popd command ...

  13. Detect drive letter change and re-assign it (usb drive letter) in

    So instead of having J: with a label "keedrive" and V: with a label "secondary", Windows will sometimes swap them, J: becomes "secondary" and V: "keedrive". I'm trying to have a Batch script that will check if the drives letter have changed and if so reset them as they were. Currently, i have to manually re-assign the letters with Diskpart utility.

  14. How to change directory to run .bat files from different drive?

    6 Answers. Use the /D switch to change current drive in addition to changing current directory for a drive. If you need to go from a device to another (in your case from C:\ to F:\, you need to type F: before/after you entered your cd command, so it will go on the F device. Otherwise, you can use the /D parameter of the cd function.

  15. Assign Drive Letter by Batch File

    Assign Drive Letter by Batch File. I have been having some problems with an external Sata hard drive on my Windows 7 PC. When I reboot, the drive does not maintain its letter. The drive is new, but I also had the same problem with another drive. If this problem can't be fixed, I would like to create a batch file to assign the drive a letter ...

  16. Need BAT file to change my drive letters

    Typically what happens is the wrong HD is assigned to G, so I have to change it's drive letter to T. I then need to assign my backup HD to G and then remove a letter F from a system reserved partition. If I had a BAT file that would do this then I could easily tweak it to solve any drive letter issue. Thanks,

  17. Batch scripting: iterate over drive letters?

    1. gwmi win32_logicaldisk | where {$_.DriveType -eq 3} for physical drives, if you want only those with drive letters (possible to not have any mount point, or could be mounted to a folder) add | where {$_.DeviceID -like "*:"}. for network drives just change the original where statement to where {$_DriveType -eq 4} (3 = Local disk, 4 = Network ...