#Initialize variables
# $VCServer = ""
#Connect to vCenter Server
#Connect-VIServer $VCServer
$i = 0
$objHba = @()
$cnt = (Get-Content clusters.txt).Count
Get-Content clusters.txt | ForEach-Object {
$i++
$currclust = $_
$cluster = Get-cluster $currclust
try{
Write-Progress -Activity "Scanning .... " -Status ("Cluster : {0}" -f $cluster) -PercentComplete ($i/$cnt*100) -Id 1
}
catch [System.DivideByZeroException]{ }
$vmhosts = $cluster | Get-vmhost
if ($null -ne $vmhosts) {
foreach ($vmhost in $vmhosts) {
$vmhostview = $vmhost | Get-View
foreach ($hba in $vmhostview.config.storagedevice.hostbusadapter) {
if ($hba.PortWorldWideName) {
#Define Custom object
$objWwpn = "" | Select Clustername,Hostname,Hba,WWNN,WWPN
#Add porperties to the newly created object
$objWwpn.ClusterName = $cluster.Name
$objWwpn.HostName = $vmhost.Name
$objWwpn.Hba = $hba.Device
$objWwpn.Wwnn = "{0:x}" -f $hba.NodeWorldWideName
$objWwpn.Wwpn = "{0:x}" -f $hba.PortWorldWideName
$objHba += $ObjWwpn
}
}
}
}
}
$objHba | Export-Csv -NoTypeInformation -UseCulture HbaInfo.csv
# $VCServer = ""
#Connect to vCenter Server
#Connect-VIServer $VCServer
$i = 0
$objHba = @()
$cnt = (Get-Content clusters.txt).Count
Get-Content clusters.txt | ForEach-Object {
$i++
$currclust = $_
$cluster = Get-cluster $currclust
try{
Write-Progress -Activity "Scanning .... " -Status ("Cluster : {0}" -f $cluster) -PercentComplete ($i/$cnt*100) -Id 1
}
catch [System.DivideByZeroException]{ }
$vmhosts = $cluster | Get-vmhost
if ($null -ne $vmhosts) {
foreach ($vmhost in $vmhosts) {
$vmhostview = $vmhost | Get-View
foreach ($hba in $vmhostview.config.storagedevice.hostbusadapter) {
if ($hba.PortWorldWideName) {
#Define Custom object
$objWwpn = "" | Select Clustername,Hostname,Hba,WWNN,WWPN
#Add porperties to the newly created object
$objWwpn.ClusterName = $cluster.Name
$objWwpn.HostName = $vmhost.Name
$objWwpn.Hba = $hba.Device
$objWwpn.Wwnn = "{0:x}" -f $hba.NodeWorldWideName
$objWwpn.Wwpn = "{0:x}" -f $hba.PortWorldWideName
$objHba += $ObjWwpn
}
}
}
}
}
$objHba | Export-Csv -NoTypeInformation -UseCulture HbaInfo.csv
No comments:
Post a Comment