{"id":75211,"date":"2015-12-08T00:01:00","date_gmt":"2015-12-08T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/12\/08\/use-deployimage-module-and-powershell-to-build-a-nano-server-part-2\/"},"modified":"2019-02-18T09:20:45","modified_gmt":"2019-02-18T16:20:45","slug":"use-deployimage-module-and-powershell-to-build-a-nano-server-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-deployimage-module-and-powershell-to-build-a-nano-server-part-2\/","title":{"rendered":"Use DeployImage Module and PowerShell to Build a Nano Server: Part 2"},"content":{"rendered":"<p><b>Summary<\/b>: Sean Kearney uses the <b>New-NanoServerWim<\/b> cmdlet from the <b>DeployImage<\/b> module to build an updated Nano Server WIM file.<\/p>\n<p>Honorary Scripting Guy, Sean Kearney, is here today continuing forward with creating a new Nano Server with the <b>DeployImage<\/b> module.<\/p>\n<p><b>&nbsp; &nbsp;Note<\/b>&nbsp;&nbsp;&nbsp;This is a five-part series that includes the following posts:<\/p>\n<ul>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/scripting\/use-deployimage-module-and-powershell-to-build-a-nano-server-part-1\/\" target=\"_blank\">Use DeployImage Module and PowerShell to Build a Nano Server: Part 1<\/a><br \/>Introducing the&nbsp;<b>DeployImage<\/b>&nbsp;module and the cmdlets for Nano Server.<\/li>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2015\/12\/08\/use-deployimage-module-and-powershell-to-build-a-nano-server-part-2.aspx\" target=\"_blank\">Use DeployImage Module and PowerShell to Build a Nano Server: Part 2<\/a><br \/>Use the&nbsp;<b>New-NanoServerWim<\/b>&nbsp;cmdlet from the&nbsp;<b>DeployImage<\/b>&nbsp;module to build an updated Nano Server WIM file.<\/li>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2015\/12\/09\/use-deployimage-module-and-powershell-to-build-a-nano-server-part-3.aspx\" target=\"_blank\">Use DeployImage Module and PowerShell to Build a Nano Server: Part 3<\/a><br \/>Use the&nbsp;<strong>New-UnattendXMLContent<\/strong>&nbsp;cmdlet in his&nbsp;<strong>DeployImage<\/strong>&nbsp;module to automate naming the Nano Server.<\/li>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2015\/12\/10\/using-deployimage-and-windows-powershell-to-build-a-nano-server-part-4.aspx\" target=\"_blank\">Using DeployImage and Windows PowerShell to Build a Nano Server: Part 4<\/a><br \/>Use the new cmdlets in the&nbsp;<b>DeployImage<\/b>&nbsp;module to simplify the deployment of a Nano Server.<\/li>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2015\/12\/11\/using-deployimage-and-windows-powershell-to-build-a-nano-server-part-5.aspx\" target=\"_blank\">Using DeployImage and Windows PowerShell to Build a Nano Server: Part 5<\/a><br \/>Use the&nbsp;<b>DeployImage<\/b>&nbsp;module to build bootable Windows PE media with deployment content.<\/li>\n<\/ul>\n<p>I&rsquo;m presuming that you have the media for the Nano Server ready, and it is sitting off the <b>NanoServer<\/b> folder at the root of the Windows Server 2016 TP4 media.<\/p>\n<p>To customize the Nano Server WIM file, we use the same process as customizing any other WIM file (which is nice&mdash;nothing new to learn):<\/p>\n<ul>\n<li>Copy the WIM file somewhere so you can have Read\/Write access to it<\/li>\n<li>Mount the WIM file to allow you to update it<\/li>\n<li>Add drivers to the offline image as needed<\/li>\n<li>Add packages to the offline image as needed<\/li>\n<li>Drop in file and registry customizations (such an Unattend.xml file)<\/li>\n<li>Dismount the image and save the changes<\/li>\n<\/ul>\n<p>I&rsquo;m going to presume that the Windows Server 2016 media is on drive X, and I&rsquo;d like to copy the <b>NanoServer<\/b> folder to drive C. I am actually going to copy the entire folder structure. I&rsquo;ll need this later when I&rsquo;m building out a USB key to deploy the Nano Server. I can do this in one line in PowerShell:<\/p>\n<p style=\"margin-left:30px\">Copy-Item &ndash;path X:\\NanoServer C:\\NanoServer &ndash;recurse<\/p>\n<p>Normally at this point, we would use DISM or <b>Mount-WindowsImage<\/b> against the file, and then begin adding packages by using <b>Mount-WindowsImage<\/b>, <b>Add-WindowsDriver<\/b>, and <b>Add-WindowsPackage<\/b>.<\/p>\n<p>Here&rsquo;s the trick&hellip;<\/p>\n<p>There are currently 15 packages available to be added to the NanoServer.wim file. For all the various combinations of the server, you&rsquo;ll have a massive pile of scripts.<\/p>\n<p>With the <b>New-NanoServerWim<\/b> cmdlet you can run a quick <b>Get-Help<\/b> to see the available options:<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/27704.1.PNG\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/27704.1.PNG\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>This cmdlet assumes that a folder called C:\\NanoTemp is your default destination, and it will create it for you to add the NanoCustom.wim file.<\/p>\n<p>The only mandatory parameter is the location of the Nano Server media folder. To target the Nano Server source on drive C (if you copied it there), you would run the following command:<\/p>\n<p style=\"margin-left:30px\">New-NanoServerWim &ndash;MediaPath &lsquo;C:\\&rsquo;<\/p>\n<p>This will take some time because it mounts the file and default to the following packages:<\/p>\n<ul>\n<li>Compute (Hyper-V and Containers)<\/li>\n<li>Clustering<\/li>\n<li>GuestDrivers (Hyper-V Guest integration)<\/li>\n<li>OEMDrivers (basic drivers)<\/li>\n<li>Defender (Windows Defender)<\/li>\n<li>DSC (Desired State Configuration client)<\/li>\n<\/ul>\n<p>But this is not the only configuration. All of the remaining parameters are switches. If you&rsquo;d like to build out the name Nano Server with IIS and File Storage added, run:<\/p>\n<p style=\"margin-left:30px\">New-NanoServerWim &ndash;MediaPath C:\\ -Storage &ndash;IIS<\/p>\n<p>If you don&rsquo;t want Hyper-V running, you must specify a <b>$False<\/b> parameter for the <b>Compute<\/b> switch:<\/p>\n<p style=\"margin-left:30px\">New-NanoServerWim &ndash;MediaPath C:\\ -Storage &ndash;IIS &ndash;Compute:$False<\/p>\n<p>When the process is complete, one object is returned&mdash;the path and file name of the new customized Nano Server WIM file.<\/p>\n<p>From this point, you could create as many different combinations as you want for basic WIM files for a virtual machine template or physical server.<\/p>\n<p>If you&rsquo;d prefer to create the custom WIM file in a different folder, you simply need to supply a different destination path, for example:<\/p>\n<p style=\"margin-left:30px\">New-NanoServerWim &ndash;MediaPath C:\\ -Storage &ndash;IIS &ndash;Compute:$False &ndash;Destination C:\\OtherTempNano<\/p>\n<p>In every case, it created a file called NanoCustom.wim in this release of the module. You&rsquo;ll have to rename it if you don&rsquo;t want it overwritten. The ability to use unique file names and prompt for overwrites may be part of a later release.<\/p>\n<p>To organize all the various cabs together, I went with a very simple If\/Then for each switch. This is not necessarily the best approach&mdash;but it does work (and it keeps the updating to a very simple cmdlet).<\/p>\n<p>Stop in tomorrow as I look in to easily creating an Unattend.xml file for this image. This will allow automatically naming the Nano Server and joining to a domain (if needed) in a pretty seamless manner.<\/p>\n<p>I invite you to follow the Scripting Guys 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 them at <a href=\"mailto: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, always remember that with great PowerShell comes great responsibility.<\/p>\n<p><b>Sean Kearney, <\/b>Honorary Scripting Guy, Cloud and Datacenter Management MVP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Sean Kearney uses the New-NanoServerWim cmdlet from the DeployImage module to build an updated Nano Server WIM file. Honorary Scripting Guy, Sean Kearney, is here today continuing forward with creating a new Nano Server with the DeployImage module. &nbsp; &nbsp;Note&nbsp;&nbsp;&nbsp;This is a five-part series that includes the following posts: Use DeployImage Module and PowerShell [&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":[56,651,154,45],"class_list":["post-75211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-nano-server","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Sean Kearney uses the New-NanoServerWim cmdlet from the DeployImage module to build an updated Nano Server WIM file. Honorary Scripting Guy, Sean Kearney, is here today continuing forward with creating a new Nano Server with the DeployImage module. &nbsp; &nbsp;Note&nbsp;&nbsp;&nbsp;This is a five-part series that includes the following posts: Use DeployImage Module and PowerShell [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/75211","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=75211"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/75211\/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=75211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=75211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=75211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}