$hasSystemFiles = $false
$disk = Get-Disk |? { $_.BusType -eq 'usb' }
If( $disk )
{
$partition = $disk | Get-Partition
If( $partition )
{
$driveletter = $partition.DriveLetter
If( -not ( [String]::IsNullOrEmpty( $driveLetter
) ) )
{
$systemDirectory = Join-Path
$driveletter “Windows\System32”
If( Test-Path $systemDirectory )
{
## whoops!
$hasSystemFiles =
$true
}
}
}
}
A bit verbose, but solid.
From: [email protected] [mailto:[email protected]] On
Behalf Of David McSpadden
Sent: Thursday, November 12, 2015 10:34 AM
To: [email protected]
Subject: RE: [NTSysADM] RE: format a USB drive command line
Yes.
The users put one in each day. And send me yesterdays.
Each night at 7:00 a copy is completed from the server E: drive to the USB W:
drive.
If the logic is already built to only get USB bustype drives, what is the logic
to look for systems files as well?
*I really don’t want to be begging you guys for help on a formatted system
drive down the road.
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of CESAR.ABREG0 .
Sent: Thursday, November 12, 2015 10:28 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: [NTSysADM] RE: format a USB drive command line
Is that the only USB drive that will ever be connected to these systems? If
not, you might need to find or set a unique identifier on them and do your
logic based on that.
I would refrain from using format or at least put logic to exist if system
files are found.
On Thu, Nov 12, 2015, 7:20 AM David McSpadden
<[email protected]<mailto:[email protected]>> wrote:
So something more like this:
Get-Disk | where-Object -FilterScript {$_.BusType -Eq "USB"} | Clear-Disk
-RemoveData -Confirm:$false
$Disk = Get-Disk | where-Object -FilterScript {$_.BusType -Eq "USB"}
Set-Disk -InputObject $Disk -IsOffline $false
Initialize-Disk -InputObject $Disk
New-Partition $Disk.Number -UseMaximumSize -DriveLetter W
Format-Volume -DriveLetter W -FileSystem NTFS -Confirm:$false
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>]
On Behalf Of Michael B. Smith
Sent: Thursday, November 12, 2015 9:35 AM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: format a USB drive command line
Yes. In an elevated powershell session, start here:
get-command get-* -module storage
Once you figure out how to uniquely identify your disk, then move to the
cmdlets that start with something like Set/Update/Format/Initialize/etc.
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Damien Solodow
Sent: Thursday, November 12, 2015 9:28 AM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: format a USB drive command line
As do server 2012 and up.
I was about to say, PowerShell FTW.
Get-volume | where drivetype –eq removable
Or
Get-disk | where bustype –eq usb
DAMIEN SOLODOW
Senior Systems Engineer
317.447.6033 (office)
317.447.6014 (fax)
HARRISON COLLEGE
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Michael B. Smith
Sent: Thursday, November 12, 2015 9:25 AM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: format a USB drive command line
What is the OS? 8/8.1/10 all have cmdlets that can deal with this kinda stuff.
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David McSpadden
Sent: Thursday, November 12, 2015 9:19 AM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: format a USB drive command line
Not really looking forward to that.
Honestly I can say not really at all.
What is the better way to do this.
Reset the USB drive to 0 bytes then copy data to a new drive each night?
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Gavin Wilby
Sent: Thursday, November 12, 2015 9:16 AM
To: '[email protected]<mailto:[email protected]>'
<[email protected]<mailto:[email protected]>>
Subject: [NTSysADM] RE: format a USB drive command line
Im looking forward to the “I have formatted my Exchange Server system
partition, can I revert this” post.
Gavin Wilby
IT Support Engineer
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David McSpadden
Sent: 12 November 2015 14:00
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: format a USB drive command line
Wanting to automate this.
Just need the human to put the drive in the uSB slot.
Let the server do the rest.
I am thinking this script:
DISKPART.exe
List Disk
Select Disk 4(USB drive will always will be disk 4)
Clean
Create Partition Primary
Select Partition=1
Format FS=NTFS Quick
Active
Assign Letter=W
Exit
Exit
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Kibble,Tony
Sent: Thursday, November 12, 2015 8:48 AM
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] RE: format a USB drive command line
If it is the same drive each time, can you not go into Disk Management when it
is connected and then assign the drive a specific letter?
Failing that you could try this utility ( which I have not tested)
http://www.uwe-sieber.de/usbdlm_e.html
Tony Kibble
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of David McSpadden
Sent: 12 November 2015 13:36
To: [email protected]<mailto:[email protected]>
Subject: [NTSysADM] format a USB drive command line
I have a department that puts a USB drive in their Fileserver every day.
I would like to run a command line to format W: /q /c /FS:NTFS /V:F10%day of
month%
However the drive letter is not always W: Some days it is D: Some H: some
whatever.
Is there a way to command line find the USB drive, (only one each day), assign
it a letter (W:)
Then run my format command and my backup (Copy) command later?
The variable for day of month I have sorted. I just need to get the drive
letter to be the same every day
So I can schedule.
Server is a 2012 R2. I can use DISKPART if needed (Will need a little guidance
if it is required.)
This e-mail and any files transmitted with it are property of Indiana Members
Credit Union, are confidential, and are intended solely for the use of the
individual or entity to whom this e-mail is addressed. If you are not one of
the named recipient(s) or otherwise have reason to believe that you have
received this message in error, please notify the sender and delete this
message immediately from your computer. Any other use, retention,
dissemination, forwarding, printing, or copying of this email is strictly
prohibited.
Please consider the environment before printing this email.
________________________________
DISCLAIMER
This material has been checked by us for computer viruses and, although none
has been found, we cannot guarantee that it is completely free from such
problems and we do not accept liability for loss or damage which may be caused.
This message is intended only for use of the individual or entity to whom it is
addressed and may contain information which may be privileged and confidential.
If you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this e-mail in error, please notify the sender
immediately via e-mail and delete the message. Thank you.
*******************************************************
Travelers Insurance Company Limited is authorised by the Prudential Regulation
Authority and regulated by the Financial Conduct Authority in the UK and is
regulated by the Central Bank of Ireland for conduct of business rules.
Registered in England 1034343. Registered as a branch in Ireland 903382.
Travelers Syndicate Management Limited is authorised by the Prudential
Regulation Authority and regulated by the Financial Conduct Authority and the
Prudential Regulation Authority. Registered in England 03207530.
Travelers Underwriting Agency Limited is authorised and regulated by the
Financial Conduct Authority. Registered in England 03708247.
Travelers Professional Risks Limited is an appointed representative of
Travelers Insurance Company Limited which is authorised by the Prudential
Regulation Authority and regulated by the Financial Conduct Authority and the
Prudential Regulation Authority. Registered in England 05201980
Travelers Management Limited. Registered in England 00972175.
The registered offices for all companies listed above is: Exchequer Court, 33
St Mary Axe, London, EC3A 8AG.
All other branch offices are available from our websites.
travelers.co.uk<http://travelers.co.uk>
travelers.ie<http://travelers.ie>
Issues to: mailto: [email protected]<mailto:[email protected]>
________________________________
This communication, including attachments, is confidential, may be subject to
legal privileges, and is intended for the sole use of the addressee. Any use,
duplication, disclosure or dissemination of this communication, other than by
the addressee, is prohibited. If you have received this communication in error,
please notify the sender immediately and delete or destroy this communication
and all copies.
TRVDiscDefault::1201
This e-mail and any files transmitted with it are property of Indiana Members
Credit Union, are confidential, and are intended solely for the use of the
individual or entity to whom this e-mail is addressed. If you are not one of
the named recipient(s) or otherwise have reason to believe that you have
received this message in error, please notify the sender and delete this
message immediately from your computer. Any other use, retention,
dissemination, forwarding, printing, or copying of this email is strictly
prohibited.
Please consider the environment before printing this email.
SMP Partners Limited, SMP Trustees Limited and SMP Fund Services Limited are
licensed by the Isle of Man Financial Services Authority. SMP Accounting & Tax
Limited is a member of the ICAEW Practice Assurance Scheme.
SMP Partners Limited registered in the Isle of Man, Company Registration No:
000908V
Directors: M.W. Denton, M.J. Derbyshire, S.E McGowan, O. Peck, J.J. Scott, S.J.
Turner
SMP Trustees Limited registered in the Isle of Man, Company Registration No:
068396C
Directors: A.C. Baggesen, J.M. Cubbon, M.W. Denton, K.M. Goldie, O Peck, J.
Watterson
SMP Fund Services Limited registered in the Isle of Man, Company Registration
No: 120288C
Directors: V. Campbell, R.K. Corkhill, M.W. Denton, D.A. Manser, S.E McGowan,
J.J. Scott
SMP Accounting & Tax Limited registered in the Isle of Man, Company
Registration No: 001316V
Directors: I.F. Begley, A.J. Dowling, P. Duchars, J.J. Scott, S.J. Turner
SMP Capital Markets Limited registered in the Isle of Man, Company Registration
No: 002438V
Directors: M.W. Denton, M.J. Derbyshire, D.F Hudson, S.E McGowan, O. Peck, J.J.
Scott.
SMP Partners Limited, SMP Trustees Limited, SMP Fund Services Limited, SMP
Accounting & Tax Limited and SMP Capital Markets Limited are members of the SMP
Partners Group of Companies.
This email is confidential and is subject to disclaimers. Details can be found
at: http://www.smppartners.com/disclaimer.html
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
This e-mail and any files transmitted with it are property of Indiana Members
Credit Union, are confidential, and are intended solely for the use of the
individual or entity to whom this e-mail is addressed. If you are not one of
the named recipient(s) or otherwise have reason to believe that you have
received this message in error, please notify the sender and delete this
message immediately from your computer. Any other use, retention,
dissemination, forwarding, printing, or copying of this email is strictly
prohibited.
Please consider the environment before printing this email.
This e-mail and any files transmitted with it are property of Indiana Members
Credit Union, are confidential, and are intended solely for the use of the
individual or entity to whom this e-mail is addressed. If you are not one of
the named recipient(s) or otherwise have reason to believe that you have
received this message in error, please notify the sender and delete this
message immediately from your computer. Any other use, retention,
dissemination, forwarding, printing, or copying of this email is strictly
prohibited.
Please consider the environment before printing this email.
This e-mail and any files transmitted with it are property of Indiana Members
Credit Union, are confidential, and are intended solely for the use of the
individual or entity to whom this e-mail is addressed. If you are not one of
the named recipient(s) or otherwise have reason to believe that you have
received this message in error, please notify the sender and delete this
message immediately from your computer. Any other use, retention,
dissemination, forwarding, printing, or copying of this email is strictly
prohibited.
Please consider the environment before printing this email.