Q
Problem solve Get help with specific problems with your technologies, process and projects.

How do you extract an ISO file before booting a VM?

Take advantage of PowerShell commands to clear ISO files from your VMs before booting and ensure their configuration is set to boot from the virtual hard drive, not the ISO.

With a few PowerShell commands and scripts, you can extract an ISO file from a VM and ensure production VMs will...

boot from the virtual hard drive.

There are a few ways to deploy the OS inside VMs: You can use Hyper-V Manager to attach an OS ISO file to the VM, or you can use the VM management console to install the OS.

An ISO file is a software installation kit that administrators can use to copy data to a disk, such as a CD or DVD. In virtual environments, the ISO file functions as the disk. Administrators sometimes install an OS using an ISO file because it saves time, but it can often limit vMotion and Distributed Resource Scheduler actions if administrators don't monitor it after deployment.

If you installed the OS inside the VMs using the ISO, you must extract the ISO file so the VMs can boot from the virtual hard drive instead of the ISO. It's often necessary to check production VMs' configuration to ensure they will boot from the virtual hard drive without an ISO file attached.

Use the Get-VMDVDDrive PowerShell cmdlet to see if any VMs have the ISO file attached and Remove-VMDVDDrive to extract the ISO file.

Execute another PowerShell command to check whether VMs on the local Hyper-V server have an ISO file attached:

Get-VM * | Get-VMDVDDrive | Select-Object VMName, Path | Export-CSV C:\Temp\VMDVDFilePath.CSV -NoTypeInfo

This command queries all VMs on the local Hyper-V server, collects ISO file paths for each VM and exports the results to a C:\Temp\VMDVDFilePath.CSV file. If you see a VM with an attached ISO file, you can take the necessary actions. If you must query all VMs for ISO files on all Hyper-V servers, execute this PowerShell script:

$HyperVHost = "C:\Temp\HyperVHosts.TXT"
$ReportFile = "C:\Temp\VMsDVDConfig.CSV"
Remove-item $ReportFile -ErrorAction SilentlyContinue
Foreach ($ThisHost in Get-Content "$HyperVHost")
{
Get-VM * -ComputerName $ThisHost | Get-VMDVDDrive | Select-Object VMName, Path | Export-CSV $ReportFile -NoTypeInfo -Append
}

This script queries all VMs on each Hyper-V host specified in C:\Temp\HyperVHosts.TXT and stores the report in a C:\Temp\VMsDVDConfig.CSV file. This command uses the Append parameter to append the output in the same file instead of replacing it. Put these PowerShell commands to use and make it easy to extract an ISO file from a VM.

This was last published in April 2018

Dig Deeper on Microsoft Hyper-V management

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

What PowerShell commands do you use to make sure your VMs are ready for production?
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close