Link to home
Create AccountLog in
Avatar of Roger Alcindor
Roger Alcindor

asked on

Windows Powershell format a USB disk

Can Anyone suggest a simple script to format a USB disk (quick format) where the disk is has a drive mapping of G:
This is to run on Microsoft Windows server 2008 R2


Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Roger Alcindor
Roger Alcindor


I forgot to mention that the windows server is running Windows Server 2008 R2 64 bit  O/S.
Does this affect your suggested script ? Also I assume that I should I use -Filter "DriveLetter = 'G:' " and not 'O' as in your code suggestion ?


sorry I misread the drive letter. I tested the script on identical os
I have tried the script but it doesn't seem to work. No error is indicated but Windows PowerShell returns the following:

__GENUS          : 2
__CLASS          : __PARAMETERS
__RELPATH        :
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 15
I have found out that 15 means cluster size too small. I tried 8192 and this worked OK, just returning a value of zero.

Thanks for your help - problem solved and points are yours.
Hi Roger,
hm, according to MSDN documentation, return code 15 means:
Cluster size is too small

What kind of USB stick is it? What size?
What is the current format (eg using the following PS command or Windows Explorer drive properties)?
$drive = Get-WmiObject -Class win32_volume -Filter "DriveLetter = 'L:'"

Open in new window

Can you format it through Windows Explorer?

OK, glad that it worked
In answer to your question, it is a DELL 320 GB removable hard disk RD1000.