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

Thanks,

Roger
LVL 2
alcindorAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Rainer JeschorConnect With a Mentor Commented:
Hi Roger,

please try this:
$drive = Get-WmiObject -Class win32_volume -Filter "DriveLetter = 'O:'"
$drive.Format("FAT32",$true,4096,"testFormat",$false)

Open in new window


HTH
Rainer
0
 
alcindorAuthor Commented:
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 ?

Thanks,

Roger
0
 
Rainer JeschorCommented:
Hi,
sorry I misread the drive letter. I tested the script on identical os
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
alcindorAuthor Commented:
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
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 15
0
 
alcindorAuthor Commented:
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.
0
 
Rainer JeschorCommented:
Hi Roger,
hm, according to MSDN documentation, return code 15 means:
Cluster size is too small
http://msdn.microsoft.com/en-us/library/aa390432(v=vs.85).aspx

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:'"
$drive

Open in new window


Can you format it through Windows Explorer?

Thanks.
Rainer
0
 
Rainer JeschorCommented:
OK, glad that it worked
0
 
alcindorAuthor Commented:
In answer to your question, it is a DELL 320 GB removable hard disk RD1000.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.