Solved

Windows Powershell format a USB disk

Posted on 2014-01-14
8
2,136 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

17 Experts available now in Live!

Get 1:1 Help Now