VMware Cloud Community
pacifierzWBG
Contributor
Contributor
Jump to solution

Need help fine tuning the storage path status script

Can somone please help with fine tuning the script to get the below details?

Output should have the pathstatus of all the LUNs (including RDMs, extent & not allocated LUNs) with below columns

 

"Date","ESXi_hostname","Name", "PathState"

Column "Name" should contain the data shown below (highlighted in yellow)

LUN.PNG

Column "PathState" - can be "Active/Standy/dead"

I got the below script from somewhere in the internet which used to work fine when running vCenter 6.0. Now that we have upgraded to 6.5, the script isn't provinding the Column "name" correctly.

For example, the Column "Name" instead of giving out as below: (please see attached - need the field Name circled in RED)

"vmhba1:C0:T1:L1,fc.200000107b1da97c:100000109a1da97c-fc.524a437f706ae713:524a437f706ae713-naa.624a8350b3e643afaf40452201171121"

it just give me this

"vmhba1:C0:T1:L1"

Please help me in correcting the script

i'm using PowerCLI 11

powercli.png

Script:

$hostList = 'D:\Scripts\HBA\PathStatus\ESXiHostList.txt'

$outputfile = 'D:\Scripts\HBA\PathStatus\Output\PathStatus.csv'

$vmhosts = Get-Content -Path $hostList

$allhostinfo = @()

$date = Get-Date -format "dd-MMM-yyyy HH:mm:ss"

foreach($vmhost in $vmhosts){

$hostinfo = ((Get-View(Get-VMHost $vmhost)).config.storagedevice.multipathinfo.Lun).Path | Select @{N="Date";E={$date}}, @{N="VMHost";E={$vmhost}}, Name, PathState, State

$allhostinfo += $hostinfo

}

$allhostinfo | Export-Csv $outputfile -noTypeInformation

http://www.vmwarealert.com/
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$date = Get-Date -format "dd-MMM-yyyy HH:mm:ss"

Get-VMHost |

ForEach-Object -Process {

   $esxcli = Get-EsxCli -VMHost $_ -V2

   $esxcli.storage.core.path.list.Invoke() |

  Select @{N='Date';E={$date}},

   @{N='VMHost';E={$esxcli.VMHost.Name}},

   @{N='Name';E={$_.Uid}},

  State

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Does this contain the data you want?

$esxName = 'MyEsx'

$esx = Get-VMHost -Name $esxName

$esxcli = Get-EsxCli -VMHost $esx -V2

$esxcli.storage.core.path.list.Invoke()


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
pacifierzWBG
Contributor
Contributor
Jump to solution

Hi LucD

Yes.. It contains the data i needed.

I need the field UID.

UID                     : fc.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-fc.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-naa.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

http://www.vmwarealert.com/
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

$date = Get-Date -format "dd-MMM-yyyy HH:mm:ss"

Get-VMHost |

ForEach-Object -Process {

   $esxcli = Get-EsxCli -VMHost $_ -V2

   $esxcli.storage.core.path.list.Invoke() |

  Select @{N='Date';E={$date}},

   @{N='VMHost';E={$esxcli.VMHost.Name}},

   @{N='Name';E={$_.Uid}},

  State

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
pacifierzWBG
Contributor
Contributor
Jump to solution

Hi LucD,

I got what i needed. You are awesome..

Thanks for your help..

http://www.vmwarealert.com/
0 Kudos