Tag: iso

Eject ISO from Hyper-V VM using PowerShell

Eject ISO from Hyper-V VM using PowerShell

This is one of these quick and dirty blog posts mostly as a note for myself. Hyper-V offers the capability to add an ISO image to a virtual CD/DVD drive and you can use Hyper-V Manager to do that, or you can also use PowerShell. Here is how you can eject or remove an ISO from a Hyper-V virtual machine (VM) using PowerShell.

This works with Hyper-V on Windows Server and on Windows 10.

Remove or eject ISO from Hyper-V VM using PowerShell

To remove or eject the ISO file from a Hyper-V VM virtual DVD drive, you can use the following PowerShell command:

Find the right DVD drive

Get-VMDvdDrive -VMName "Windows10"

Eject the ISO file from the Hyper-V VM

Get-VMDvdDrive -VMName "Windows10" | Set-VMDvdDrive -Path $null

You can also pipe these commands

Get-VM -VMName "Windows10" | Get-VMDvdDrive | Set-VMDvdDrive -Path $null

If you have multiple DVD drives and controllers on VM, you can also use the following command to be more specific on which ISO to eject.

Set-VMDvdDrive -VMName Windows10 -ControllerNumber 0 -ControllerLocation 1 -Path $null

You can also simply add an ISO to the Hyper-V virtual DVD drive:

Get-VMDvdDrive -VMName "Windows10" | Set-VMDvdDrive -Path "C:\ISO\myisofile.iso"

Be aware that it takes a moment until the ISO file is removed from the virtual DVD drive. You can find more information on the Set-VMDvdDrive cmdlet on Microsoft Docs.

Conclusion

If you want to build some automation around Hyper-V on Windows 10 or on Windows Server, PowerShell is the way to go. If you have any questions feel free to leave a comment.



Add ISO DVD Drive to a Hyper-V VM using PowerShell

Add ISO DVD Drive to a Hyper-V VM using PowerShell

Hyper-V offers the capability to add an ISO image to a virtual CD/DVD drive and you can use Hyper-V Manager to do that, or you can also use PowerShell. Here is how you can add an ISO to a Hyper-V virtual machine (VM) using PowerShell. There are two ways of doing it if you already have a virtual DVD drive attached to the VM or if you need to add a virtual DVD drive.

This works with Hyper-V on Windows Server and on Windows 10.

Attach ISO to an existing DVD Drive on a Hyper-V VM using PowerShell

To attach an ISO file to an existing virtual DVD drive on a Hyper-V virtual machine (VM) using PowerShell, you can use the following command:

Set-VMDvdDrive -VMName Windows10 -Path "C:\Users\thoma\Downloads\ubuntu-18.04.4-live-server-amd64.iso"

Add ISO file and DVD Drive to a Hyper-V VM using PowerShell

If your Hyper-V virtual machine doesn’t have a virtual DVD drive attached to it, you can add a virtual DVD drive including the ISO file with the following PowerShell command:

Add-VMDvdDrive -VMName "Windows10" -Path "C:\Users\thoma\Downloads\ubuntu-18.04.4-live-server-amd64.iso"

If you run this command on a virtual machine, which already has a virtual DVD drive attached, you will simply add a second virtual DVD drive to this machine. You can find more information on the Add-VMDvdDrive cmdlet on Microsoft Docs.

Conclusion

If you want to build some automation around Hyper-V on Windows 10 or on Windows Server, PowerShell is the way to go. If you have any questions feel free to leave a comment.



Hyper-V Server 2019 Install now

How to Install Hyper-V Server 2019

A couple of weeks ago Microsoft released the installation media, and you can download Hyper-V Server 2019 right now. In this blog post, I am going to show you how to install and configure Hyper-V Server 2019 step by step. This should especially help beginners with Hyper-V Server 2019. Hyper-V Server 2019 ships only a core option, so there won’t be desktop experience version of Hyper-V Server like you would have with Windows Server 2019.

Hyper-V Server 2019 Requirements

Hyper-V has specific hardware requirements to run virtualization in a secure and performant way.

  • 64-bit processor with second-level address translation (SLAT)
  • Minimum of 4GB of RAM. You will need more RAM for virtual machines on the Hyper-V Server.
  • Virtualization features and support needs to be enabled in BIOS or UEFI
    • Hardware-assisted virtualization – Intel Virtualization Technology (Intel VT) or AMD Virtualization (AMD-V) technology.
    • Hardware-enforced Data Execution Prevention (DEP)  Intel XD bit (execute disable bit) or AMD NX bit (no execute bit).

Specific features, like Discrete device assignment (DDA) or Shielded Virtual Machines, will also have other hardware requirements. You can find more about the Hyper-V Server 2019 requirements on Microsoft Docs.

Download ISO

You can download Hyper-V Server directly from the Microsoft evaluation center. This SKU does not require a license key, and it also doesn’t expire. It is a fully supported version of Hyper-V for free. However, if you run workloads like Windows Server, Windows 10, or other operating systems on top of it, they need to be correctly licensed.

Install Hyper-V Server 2019

After you have download the ISO file, you will need to install this on your machine. There are multiple options to do this:

You can also follow this guide to add drivers to a Windows Server Image; this also works for Hyper-V Server.

Now you can boot your server with the Hyper-V installation media. This will start the step by step installation. Select the language and region settings you want to use for your Hyper-V Server.

Install Hyper-V Server 2019

Install Hyper-V Server 2019



PowerShell Get-WindowsImage Windows Server 2019 Editions

Add Drivers to a Windows Server 2019 ISO Image

In this blog article, I am going to show you how you can add drivers to a Windows Server 2019 ISO Image or WIM file using PowerShell and the DISM module. This will allow you to already have the latest drivers within the Windows Server installation image when you install Windows Server 2019. We will add drivers to a Windows Server 2019 WIM file (WIM stands for Windows Imaging Format), which then can be used to create a new ISO image or for example in Windows Deployment Services.

Preparation

Folder for adding drivers to Windows Server 2019

Folder for adding drivers to Windows Server 2019

First, you will need to create three new folders called Drivers, ISO, and Mount. In my example, I created these in C:\Images.

  • Drivers – This is the folder where you put all your extracted drivers, which you want to add to your Windows Server 2019 Image.
  • ISO – This is where you can extract the Windows Server 2019 ISO Image. Basically all the files on the ISO file.
  • Mount – This is an empty folder, which will be used to mount the WIM files.

You can now mount the ISO using Windows Explorer or the following PowerShell commands and copy the files to the ISO folder.

Mount ISO PowerShell

Mount ISO PowerShell

Mount-DiskImage -ImagePath C:\Temp\17763.379.190312-0539.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso
Copy-Item D:\* C:\Image\ISO\ -Recurse

In your case, the ISO may be mounted on a different drive letter instead of my D: drive.

Add drivers to the Windows Server 2019 Image

First, you can check in which Windows editions you want to add the drivers. To check that you can use the following PowerShell command:

Get-WindowsImage -ImagePath C:\Image\ISO\sources\install.wim
PowerShell Get-WindowsImage Windows Server 2019 Editions

PowerShell Get-WindowsImage Windows Server 2019 Editions

The Get-WindowsImage cmdlet will show you the different editions included in the WIM file.

After we have seen the Index numbers, we can now mount the Windows Image our Mount folder. In my example, I use Image Index 3, which is the Windows Server 2019 Datacenter Core Edition. If you want to check which editions of Windows Server 2019 you should use, check out the Microsoft Docs.

Mount-WindowsImage -Path C:\Image\Mount -ImagePath C:\Image\ISO\sources\install.wim -Index 3
Mount-WindowsImage

Mount-WindowsImage

After the image is mounted you can now add the drivers to the Windows Server 2019 Image using the following command:

Add-WindowsDriver -Path C:\Image\Mount -Driver C:\Image\Drivers -Recurse
Add Drivers to Windows Server 2019 ISO Image

Add Drivers to Windows Server 2019 ISO Image

After you have added all the drivers to the image, you need to dismount the image and save it.

Dismount-WindowsImage -Path C:\Image\Mount -Save

We have now added the drivers to the Install image, and you should also add the drivers to your boot image if it is, for example, a network or storage controller driver you might need to install the server. To do this do the same steps to the C:\Image\ISO\sources\boot.wim.

Now you can use these WIM files with Windows Deployment services or create a USB drive to install Windows Server 2019. If you want to create an ISO file, you can use the oscdimg command-line tool. The oscdimg tool comes with the Windows Assessment and Deployment Kit (Windows ADK), which you can get here.

oscdimg -n -m -bc:\temp\ISO\boot\etfsboot.com C:\temp\ISO C:\temp\mynew.iso

I hope this post helps you to add drivers to your Windows Server image. If you have any questions, feel free to leave a comment.



Windows Server 2019 USB Drive

Create a USB Drive for Windows Server 2019 Installation

This blog post covers how you can create a bootable USB media drive to install Windows Server 2019 on a physical server. This blog post will not use any third-party tools; it only uses built-in tools that you can find on Windows 10 or Windows Server. Depending on your system you will need it to install it on a BIOS system or a UEFI based system, which is slightly different since UEFI will use GPT disks and BIOS will use an MBR disk. Here is how you create a USB Drive for a Windows Server 2019 installation.

Getting ready to create a USB Drive for a Windows Server 2019 Installation

First, you will need to have all the prerequisites in place.

  • Download the Windows Server 2019 ISO File
  • A USB Drive with at least 8GB size



Nano Server Image Builder

Create a Nano Server using the Nano Server Image Builder

Last week Microsoft released Windows Server 2016 to the public and at the weekend Microsoft released the Nano Server Image Builder. I already wrote a few blog posts how you can create new Nano Server Images using PowerShell. The Nano Server Image Builder is a UI based wizard to create new Nano Server Images. The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with a graphical interface. Based on the inputs you provide, it generates images for deployment and it also creates reusable PowerShell scripts that allow you to create installations of Nano Server.

The Nano Server Image Builder can help you with the following tasks:

  • Graphical UI to create Nano Server Images
  • Adding drivers
  • Choose Windows Server Edition
  • Adding roles and features
  • Adding drivers
  • Adding updates
  • Configuration of Network Settings
  • Configuration of Domain settings
  • Set Remoting Options
  • Create an ISO file to boot from DVD or BMC (remote connection like HP ILO)

First download and install the Windows Assessment and Deployment Kit (ADK) and the Nano Server Image Builder.

I will not go trough all the options but here is just quickly how you can use it.

First create a new Nano Server Image (this can be a VHD, VHDX or WIM file. If you want to use it on a USB drive or ISO save it as a WIM file)

Nano Server Image Builder

Make sure you have prepared everything like the Windows Server 2016 files and drivers etc

Prepapre Nano Server Files

Select the Windows Server 2016 source

Nano Server Sources

Set more options, choose packages (roles and feature), drivers and more.

Nano Server Packages and Drivers

You can also configure some advanced options

Nano Server Image Builder Advanced Configuration

You can now create the Nano Server Image. The Nano Server Image Builder will also show you the PowerShell command to create more Nano Servers.

Nano Server Image Builder PowerShell Creation

You can also use this tool to create a bootable USB drive or ISO using an existing Nano Server Image.

Select the Nano Server Image you have already created

Nano Server Image Builder WIM file

As an option you can also create a ISO file

Nano Server Image ISO

 

You can now boot from USB drive or ISO and you can get the following WinPE Image to boot and this copies the Nano Server Image to the server

Nano Server WinPe

If you want to know more, check out the blog post from Scott Johnson (Microsoft): Introducing the Nano Server Image Builder



diskpart fat32 and gpt

How to create Windows Server bootable USB media for deployment on UEFI based systems

When you were create a USB media for PCs, notebooks and servers which were using BIOS you could use several tools to do this. Now most of the tools do not really create a USB media drive which can be used to boot and install Windows or Windows Server on a UEFI based system such a new servers and for example the Surface Pro line. But it is very simple to do this now, just follow this steps:

  • The USB drive has to be formatted in FAT32
  • The USB needs to be GPT and not MBR
  • Copy all files from the ISO to the USB drive

diskpart fat32 and gpt

PowerShell to create a Windows Server USB drive

This is it, and here is how you do it:

First plugin your USB drive to your computer. The USB drive should be bigger than 4GB.

Open a CMD prompt or PowerShell using the Run as Administrator option and open diskpart. Now you can do list all this by using

 
list disk

Select the USB disk, in my case this was disk 1

 
select disk 1

Clean the disk. Be careful this will remove all files and partitions on the USB media.

 
clean

Now convert it to GPT

 
convert gpt

Create a new primary partition. But make sure the partition is not greater than 16GB otherwise it can be formatted with FAT32.

 
create partition primary
 
# If your USB drive is bigger than 16GB use the following command
 
create partition primary size=16000

Format the partition with FAT32

 
format fs=FAT32 quick

Assign a drive letter to the volume

 
assign letter=k

now you can exit the diskpart and copy all files from the Windows or Windows Server to the USB drive and boot it. This works with Windows 8, Windows 8.1, Windows 10, Windows Server 2012, Windows Server 2012 R2 and Windows Server 2016 or even Hyper-V Server in the same editions.