{"id":4765,"date":"2012-10-26T00:01:00","date_gmt":"2012-10-26T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/10\/26\/use-powershell-to-create-a-bootable-usb-drive\/"},"modified":"2012-10-26T00:01:00","modified_gmt":"2012-10-26T00:01:00","slug":"use-powershell-to-create-a-bootable-usb-drive","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-create-a-bootable-usb-drive\/","title":{"rendered":"Use PowerShell to Create a Bootable USB Drive"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft PFE Jason Walker talks about creating a Windows PowerShell script to create a bootable USB drive.\nMicrosoft Scripting Guy, Ed Wilson, is here. Today,&nbsp;The Scripting Wife and others&nbsp;will be heading to Atlanta for the <a href=\"http:\/\/powershellsaturday.com\/003\/\" target=\"_blank\">PowerShell Saturday #003 event<\/a> 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.\nJason 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&rsquo;t matter if it&rsquo;s Exchange-related or not. Jason also actively participates in the <a href=\"http:\/\/powershellgroup.org\/charlotte.nc\" target=\"_blank\">Charlotte PowerShell Users Group<\/a>.\nTwitter: AutomationJason\nHere&rsquo;s Jason &hellip;\nWith the release of Windows&nbsp;8 and Windows Server&nbsp;2012, there are thousands of additional new cmdlets at an IT Pro&rsquo;s disposal&mdash;making our lives so much easier. The storage cmdlets are an example of this.&nbsp;\nIn the past, to create a bootable USB drive to install an operating system, you could download the <a href=\"http:\/\/www.microsoftstore.com\/store\/msstore\/html\/pbPage.Help_Win7_usbdvd_dwnTool\" target=\"_blank\">Windows&nbsp;7 USB tool<\/a>, or you had to mount the ISO file with a non-Microsoft tool, copy the install bits, and then run a series of <b>DiskPart<\/b> commands.\nNow, a bootable USB is easily created without needing DiskPart.exe or a non-Microsoft tool to mount the ISO file. Windows&nbsp;8 has the ability to mount an ISO or VHD by simply double-clicking the file.\nHere are the commands to accomplish this the old way:\nFrom an elevated shell:<\/p>\n<ol start=\"1\">\n<li>DiskPart.exe<\/li>\n<li>List disk<\/li>\n<li>Select disk 1&mdash;disk 1 being the USB drive<\/li>\n<li>Clean<\/li>\n<li>Create partition primary<\/li>\n<li>Select partition 1&mdash;partition 1 being the new partition<\/li>\n<li>Active<\/li>\n<li>Format FS=NTFS<\/li>\n<\/ol>\n<p style=\"padding-left: 30px\">After you are past the series of DiskPart commands from the boot directory of the install bits, go to step 9.<\/p>\n<ol start=\"9\">\n<li>&nbsp;bootsect.exe \/NT60 G: &#8211; (G: being the USB drive)<\/li>\n<\/ol>\n<p>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.\nNow for the new Windows PowerShell way:<\/p>\n<ol start=\"1\">\n<li>Get-Disk&mdash;this is needed to get the disk number of the USB<\/li>\n<li>Clear-Disk &ndash;Number 1<\/li>\n<li>New-Partition &ndash;DiskNumber 1 &ndash;UseMaximumSize &ndash;IsActive:$true<\/li>\n<li>Format-Volume &ndash;FileSystem NTFS &ndash;DriveLetter G<\/li>\n<li>bootsect.exe \/NT60 G:<\/li>\n<\/ol>\n<p>Use <b>Copy-Item<\/b> to copy your install bits to the USB drive and you&rsquo;re done. Wait, there&rsquo;s more! The storage module has a <b>Mount-DiskImage<\/b> cmdlet. Now the entire process can be scripted with all Microsoft tools. Here is my version with it all put together.&nbsp;You can <a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/New-BootableUSB-96108e68\" target=\"_blank\">download the complete script <\/a>from the script repository. It vastly simplifies things and, not only that, it contains help, too.<\/p>\n<p style=\"padding-left: 30px\"><b>Note<\/b>&nbsp; &nbsp;The version of Windows PowerShell&nbsp;3.0 for Windows&nbsp;7 does not contain the Storage module at this time, so Windows&nbsp;8 or Windows Server&nbsp;2012 is a requirement.\nThank you, Jason.\nI invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.\n<b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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,&nbsp;The Scripting Wife and others&nbsp;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 [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[374,56,338,362,3,12,45],"class_list":["post-4765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-disks","tag-guest-blogger","tag-jason-walker","tag-powershell-3","tag-scripting-guy","tag-storage","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>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,&nbsp;The Scripting Wife and others&nbsp;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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4765"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4765\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}