Solved

Windows Powershell format a USB disk

Posted on 2014-01-14
8
2,919 Views
Last Modified: 2014-01-14
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
0
Comment
Question by:alcindor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39779874
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
 
LVL 2

Author Comment

by:alcindor
ID: 39779891
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
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39779956
Hi,
sorry I misread the drive letter. I tested the script on identical os
0
IoT Devices - Fast, Cheap or Secure…Pick Two

The IoT market is growing at a rapid pace and manufacturers are under pressure to quickly provide new products. Can you be sure that your devices do what they're supposed to do, while still being secure?

 
LVL 2

Author Comment

by:alcindor
ID: 39780098
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
 
LVL 2

Author Comment

by:alcindor
ID: 39780165
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
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39780172
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
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39780173
OK, glad that it worked
0
 
LVL 2

Author Comment

by:alcindor
ID: 39780342
In answer to your question, it is a DELL 320 GB removable hard disk RD1000.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question