Solved

Windows Powershell format a USB disk

Posted on 2014-01-14
8
2,586 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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…

679 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