250 USB drives to load? WHERE IS MY POWERSHELL CAPE???

250 USB drives to load? WHERE IS MY POWERSHELL CAPE???

In preparation for SharePoint Saturday New Hampshire I had to load 250 USB drives with sponsor’s digital collateral. The fun last evening was getting all of the little buggers out of their individual boxes and sealed plastic wrappers in order to make loading them a bit faster.

Today I ran out to Best Buy and purchased a pair of Belkin 7-Port USB 2.0 Powered Hubs and then sat down to “borrow” some PowerShell commands from someone on the interwebs. Sadly, I did not find a quick pre-canned script that would let me loop through my USB sticks and load them with the data. Here is what I needed my script to do:

1.) Change the name of the USB Drive to “SPSNH 2012”
2.) Copy the files and folders from the location on my hard drive to the USB Drives
3.) With a single trigger, perform the above functions on all drives inserted in the machine

In order to accomplish this I created a drivelist.txt file. Very simple text file with the list of drive letters that I were assigned to the drives when inserted. One key tip here is to make sure that there are no extraneous carriage returns after the final drive letter (this will cause an error later). The contents of the text file look like this:


Next I created a PowerShell script that utilized the WmiObject, WmiInstance & Item command-lets and threw in a foreach loop. The script looked like this:


Using this script, 2 computers & the 2 Belkin hubs I was able to load all almost 100meg on to 250 drives in just under 2 hours with distractions. Not too shabby.

I also created a second script for USB drives that are larger than 4GB that will reformat them as NTFS (or whatever format you choose) so that you can load larger files onto them, then rename the drive & copy the files in. Here is what that script looks like:


Hopefully this will be useful for others in the future. I would not want to be loading these things up without some form of script to assist. Below you can find a plain text version of each of these scripts that you can download and use yourself.

notepad USB Drive rename & copy script (FAT32)

notepad USB Drive format, rename & copy script (NTFS)

Comments are closed.