imageteam - Fotolia
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.
Dig Deeper on IT systems management and monitoring
Related Q&A from Nirmal Sharma
Use System Center Virtual Machine Manager and PowerShell to make logical network management easy. Execute a script to display network virtualization ... Continue Reading
Hyper-V replication is easy to use, but there are a number of steps you should take during Hyper-V replication setup to ensure you stay abreast of ... Continue Reading
Manage Hyper-V clusters more easily with PowerShell cmdlets and scripts that automate the retrieval and display of node information, including node ... Continue Reading