script to check dead lun path

    
###########################################################################################
# Description:
# document output : DeadLunPath.csv
###########################################################################################

##################
# Add VI-toolkit #
##################
& {
$ErrorActionPreference = "silentlycontinue"
$vmwareSnap = get-pssnapin -name "VMware.VimAutomation.Core"
if (! $?)
{
 Add-PSsnapin VMware.VimAutomation.Core
 Initialize-VIToolkitEnvironment.ps1
}
}

##############################################################
# replace vcenter name by vcenter host name                  #
##############################################################
$vcserver = "Vcenter name"
connect-VIServer $vcserver
$filelocation1="c:\temp\DeadLunPath.csv"
$TranscriptFile = "c:\temp\logfile.log"
Start-Transcript -Path $TranscriptFile

function DeadLunPath
{
 Write-host "Processing"
 $report = @()
 $hosts = get-vmhost
 foreach ($unHost in ($hosts | where {$_.State -eq "Connected" -or $_.State -eq "Maintenance"}))
 {
  $deadluns = @()
  $esxPaths = Get-ScsiLun -vmhost $unHost | Get-ScsiLunPath
 
  foreach ($esxPath in $esxPaths)
  {
   if ($esxPath.state -eq "Dead")
   {
    $myObj = "" | Select VMHost, Lunpath, State
    $myObj.VMHost = $unHost
    $myObj.Lunpath = $esxlun.Lunpath
    $myObj.State = $esxlun.state
    $deadluns += $myObj
   }   
  }
 
  if(($deadluns | Measure-Object).count -gt 0)
  {
   $myObj = "" | Select "Host", "Dead path count"
   $myObj."Host" = $unHost.Name
   $myObj."Dead path count" = ($deadluns | Measure-Object).count
  
   $report += $myObj
  }
 }
 $report | sort "Host" | Export-CSV $filelocation1 -NoTypeInformation
}

DeadLunPath
##############################
# Disconnect session from VC #
##############################
disconnect-viserver -confirm:$false
Stop-Transcript
#######################################################
# end of script #
#######################################################

Commentaires

Messages les plus consultés de ce blogue

VMware Explore 2024 Party list events

VMware Explore 2025 registration is now live and there is some great improvements

Changement dans les licences VMware à compter du 10 avril 2025