Learn about Windows PowerShell
Summary: Microsoft PFE Jason Walker talks about creating a Windows PowerShell script to create a bootable USB drive.
Microsoft Scripting Guy, Ed Wilson, is here. Today, The Scripting Wife and others will be heading to Atlanta for the PowerShell Saturday #003 event that takes place tomorrow. Sadly, I woke up with no voice and a stuffy head amd am staying home.Jason Walker, a speaker at the event, is our guest blogger and shares with us a script and his blog about that script. Be sure to come to the Microsoft Alpharetta Office tomorrow to see Jason and several other Windows PowerShell speakers share their knowledge with you during Windows PowerShell Saturday.
Jason Walker is a Premier Field Engineer (PFE) at Microsoft who supports customers in the public sector arena. His primary job is supporting Exchange, but he jumps at the opportunity to flex his Windows PowerShell muscles to resolve any issue that may come up. It doesn’t matter if it’s Exchange-related or not. Jason also actively participates in the Charlotte PowerShell Users Group.
Here’s Jason …
With the release of Windows 8 and Windows Server 2012, there are thousands of additional new cmdlets at an IT Pro’s disposal—making our lives so much easier. The storage cmdlets are an example of this.
In the past, to create a bootable USB drive to install an operating system, you could download the Windows 7 USB tool, or you had to mount the ISO file with a non-Microsoft tool, copy the install bits, and then run a series of DiskPart commands.
Now, a bootable USB is easily created without needing DiskPart.exe or a non-Microsoft tool to mount the ISO file. Windows 8 has the ability to mount an ISO or VHD by simply double-clicking the file.
Here are the commands to accomplish this the old way:
From an elevated shell:
After you are past the series of DiskPart commands from the boot directory of the install bits, go to step 9.
Assuming the ISO is already mounted, now you can copy all the files from the ISO. Then, you are finally ready to install your operating system.
Now for the new Windows PowerShell way:
Use Copy-Item to copy your install bits to the USB drive and you’re done. Wait, there’s more! The storage module has a Mount-DiskImage cmdlet. Now the entire process can be scripted with all Microsoft tools. Here is my version with it all put together. You can download the complete script from the script repository. It vastly simplifies things and, not only that, it contains help, too.
Note The version of Windows PowerShell 3.0 for Windows 7 does not contain the Storage module at this time, so Windows 8 or Windows Server 2012 is a requirement.
Thank you, Jason.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy
Found this minutes after posting for the very reason you posted it. Thank you! =]
Missed you Saturday, hope you're feeling better.
While the wait for mounting ISO's has been forever coming! Sooooo glad it's here now, this is so helpful! Love the script btw!
Great tool Jason, Thanks for sharing!
Thanks Jason. Had a good time learning how to make bootable usb drives with the help of your tutorial .... way better than buying a fancy app just to make bootable media :)
I had some problems finding the disk , after the new-partition command i added -assigndriveletter . Then i actually found it.
New-Partition –DiskNumber 1 –UseMaximumSize –IsActive:$true
It's NOT assigned DriveLetter
is it possible booting MS-powershell with most important drivers like VGA,keyboard, Net/WLAN etc. from USB ?
Yo is right, the command No.3 should be like.
New-Partition -DiskNumber 2 -UseMaximumSize -AssignDriveLetter -IsActive:$true