ok, so this is a new series of blog posts, the purpose is to show you SIMPLE PowerShell Cmdlets and scripts that could be useful on a daily basis.
Scenario:
You have multiple Hyper-V hosts with multiple VMs, some of them might use ISO images. You really would like to know which VM has what ISO image mounted.
Solution:
This will display all VMs and the corresponding ISO from HOST01 to HOST04
Get-VM -ComputerName HOST01,HOST02,HOST03,HOST04 | Get-VMDvdDrive | select VMName,Path
This will display all VMs and the corresponding ISO from the local Hyper-V
Get-VM | Get-VMDvdDrive | select VMName,Path
Remediation:
This will set the ISO image to NONE on the VM DEMO on the host HOST03
Get-VM DEMO -ComputerName HOST03 | Get-VMDvdDrive | Set-VMDvdDrive -Path $null
This will set the ISO image to NONE on all VMs on the local Hyper-V
Get-VM | Get-VMDvdDrive | Set-VMDvdDrive -Path $null
Output:
Categories: PowerShell