The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • Archives

  • Meta

PowerShell is King – Does my VM has any ISO mounted?

Posted by Mikael Nystrom on January 14, 2013

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:

image

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: