We help IT Professionals succeed at work.

Is there a way to make DISKPART dynamic?

Experts,

We have a DISKPART script that singles out drives and basically formats and assigns a drive letter to the particular drive we're looking at.

This is all VERY static configurations, in that we target DriveID 0, 1, 2 etc.  Any time we need to change something, we need to update the script.

Is there a way to have DISKPART just go ahead and rip through all available drives and assign drive letters in sequence?

I've tried a VbScript to accomplish this, but if the obj.Drives.IsReady is false, there's not much I can do with the drive.

Would anybody happen to have any information on this sort of stuff?  Basically, I'd like to take all physical drives that aren't currently assigned a drive letter - and assign them the next available one on the system.  Including drives that are "offline", "not ready" or any other combination possible.
Comment
Watch Question

Commented:
According to the docs (http://technet.microsoft.com/en-us/library/cc766465%28WS.10%29.aspx), when using the ASSIGN command, "If no drive letter or mount point is specified, then the next available drive letter is assigned."

Author

Commented:
Ah.  Thank you for that.  I didn't realize.

That will solve the issue of having to map them statically, but would you happen to know if it's possible to give DISKPART logic on the first half, where it grabs Drive0,1,2 etc. if they're not already assigned drive letters?
Commented:
Hmm.  

Well, since you are comfortable with scripting, how about having a script that contains simply "LIST DISK" and pipe the output to a file?  You could use the script to find the disks, and with that info, create a second script to "SELECT DISK x" and "DETAIL DISK" for each of the disks and pipe that to a file.

With that, you should have all the info you need to write the "real" script that does what you want.

A little clunky, but it should work.

Author

Commented:
Acutally,

That's a very nice idea!  - I hadn't thought of piping to txt then parsing through VB.

I'll see what I can come up with.  Thanks for the ideas.