Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

There's more...

This recipe uses the default settings for networking based on DHCP and only applies the guest package to your new VM. You can define networking and packages at deployment time. Review online documentation for New-NanoServerImage: https://technet.microsoft.com/en-us/library/mt791180.aspx.

In step 4, you import the NanoServerImageGenerator module explicitly. You could also copy the module to your local module store. You can use any folder contained in $PSModulePath. Adding the module to your module store removes the need to import the module explicitly.

In step 7, you define the path to the VHD file. You should use the .vhdx extension for a VM generation 2 image, or the .vhd extension for a VM generation 1 image.

In step 10, you create the Nano Server VM. You store the VM file configuration files in the same folder as the VM disk. Additionally, the generation specified in this command needs to correspond to the choice of file extension in step 7. For a generation 1 VM use .vhd, and for a generation 2 VM use .vhdx. You may find yourself creating various Nano Servers in your learning process. To clean up a Nano Server VM, run the following commands:

    Stop-VM -Name $NanoComputerName
    Remove-VM -Name $NanoComputerName 
    Dismount-DiskImage -ImagePath $Server2016ISOPath
  

You use this VM in the later recipes of this chapter.