Solved

Windows Powershell format a USB disk

Posted on 2014-01-14
8
2,281 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
 
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
[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now