Posted in
Virtual Machine Manager,
Windows Powershell |
No Comment | 1,863 views | 28/01/2014 15:56
You can use following script to get vHBA WWN information of virtual machines.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| $Clusters = Get-Content Clusters.txt
$Counter = 0;
foreach ($Cluster in $Clusters)
{
$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
foreach ($ClusterNode in $ClusterNodes)
{
$VMs = Get-VM -ComputerName $ClusterNode
foreach ($VM in $VMs)
{
$vHBAs = $VM.FibreChannelHostBusAdapters
if ($vHBAs)
{
Write-Host " "
Write-Host " "
Write-Host $VM.Name
$Counter++
Write-Host " "
foreach ($vHBA in $vHBAs)
{
Write-Host SanName: $vHBA.SanName
Write-Host SetA: $vHBA.WorldWidePortNameSetA
Write-Host SetB: $vHBA.WorldWidePortNameSetB
Write-Host " "
}
}
}
}
}
Write-Host Total VM: $Counter |
$Clusters = Get-Content Clusters.txt
$Counter = 0;
foreach ($Cluster in $Clusters)
{
$ClusterNodes = Get-Cluster $Cluster | Get-ClusterNode
foreach ($ClusterNode in $ClusterNodes)
{
$VMs = Get-VM -ComputerName $ClusterNode
foreach ($VM in $VMs)
{
$vHBAs = $VM.FibreChannelHostBusAdapters
if ($vHBAs)
{
Write-Host " "
Write-Host " "
Write-Host $VM.Name
$Counter++
Write-Host " "
foreach ($vHBA in $vHBAs)
{
Write-Host SanName: $vHBA.SanName
Write-Host SetA: $vHBA.WorldWidePortNameSetA
Write-Host SetB: $vHBA.WorldWidePortNameSetB
Write-Host " "
}
}
}
}
}
Write-Host Total VM: $Counter
You should add your cluster nodes into clusters.txt file.