Hi again,
In my last post I explained how to list all your virtual disks from one standalone Hyper-V Host. Today I want to give you an example of how to get all your virtual disks information from all your Hyper-V hosts that are part of a cluster.
Powershell in Windows Server 2012 is amazing and with this small script you can quickly get the information
$nodes = Get-ClusterNode
Foreach($node in $nodes)
{
$VMs=Get-VM -ComputerName $node.name
foreach($VM in $VMs ){Get-VHD -ComputerName $node.Name -VMId $VM.VMId}
}
The ouput will be the same as the last script for standalone Hyper-V hosts, but you can filter by those attributes that may be relevant for you instead of dumping all the information. For example
$nodes = Get-ClusterNode
Foreach($node in $nodes)
{
$VMs=Get-VM -ComputerName $node.name
foreach($VM in $VMs )
{
$vm.VMName
Get-VHD -ComputerName $node.Name -VMId $VM.VMId | ft vhdtype,path -AutoSize
}
}
Note:
Constrained delegation for CIFs will be required if your virtual disks are stored on SMB shares to make this script work. If not, the script will only list those virtual disks of the host from where you are running the script and will give you an Access Denied for the other hosts.
Stay tuned. After christmas I will blog how to get this information using WMI.
Merry Christmas and Happy 2013!