Hi All, I'm using the below scrip^t to retreive disks details, I need assistance to collect also the ESXi name
&{Get-VMhost | %{ |
$esxcli = Get-esxcli -VMHost $_ |
$esxcli.storage.core.path.list() |
}} | Export-Csv -path ..\Get_Local_Disks.csv |
with the above script I'm getting the below details
Adapter
AdapterIdentifier
AdapterTransportDetails
Channel
Device
DeviceDisplayName
LUN
MaximumIOSize
Plugin
RuntimeName
State
Target
TargetIdentifier
TargetTransportDetails
Transport
UID
Thank you in advance for your assistance
when you say 'ESXi name' do you mean the host name? and you just want that added as a column in the CSV?
yep, you are right, as I have 5 vcenters and need to retreive disks details
Give this a shot:
foreach ($vmhost in $hostlist){
$vmhostname = $vmhost.name
$esxcli = Get-esxcli -VMHost $vmhost
$data = $esxcli.storage.core.path.list()
$data | Add-Member NoteProperty ESXi $vmhostname
$data | Export-Csv -path ..\Get_Local_Disks.csv
}
Thank you very much
Just one question, previously I'm able to retreive local disk info for the ESXi, but now only external disks are showing
is that normal?
That is interesting. When I run the commands, I get Local disks including CD-Roms.
Adapter : vmhba0
AdapterIdentifier : sas.54cd98f06cbad300
AdapterTransportDetails : 54cd98f06cbad300
Channel : 2
Device : naa.64cd98f06cbad3002598b5d746cc145f
DeviceDisplayName : Local DELL Disk (naa.64cd98f06cbad3002598b5d746cc145f)
LUN : 0
MaximumIOSize : 1048576
Plugin : NMP
RuntimeName : vmhba0:C2:T0:L0
State : active
Target : 0
TargetIdentifier : sas.6098b5d746cc145f
TargetTransportDetails : 6098b5d746cc145f
Transport : sas
UID : sas.54cd98f06cbad300-sas.6098b5d746cc145f-naa.64cd98f06cbad3002598b5d746cc145f
ESXi : XXX
Adapter : vmhba32
AdapterIdentifier : usb.vmhba32
AdapterTransportDetails : Unavailable or path is unclaimed
Channel : 0
Device : mpx.vmhba32:C0:T0:L0
DeviceDisplayName : Local USB CD-ROM (mpx.vmhba32:C0:T0:L0)
LUN : 0
MaximumIOSize : 32768
Plugin : NMP
RuntimeName : vmhba32:C0:T0:L0
State : active
Target : 0
TargetIdentifier : usb.0:0
TargetTransportDetails : Unavailable or path is unclaimed
Transport : usb
UID : usb.vmhba32-usb.0:0-mpx.vmhba32:C0:T0:L0
ESXi : XXX
I confirm it's strange, I tested twice and same result, no local disk retreived...
what also strange is that it provide only 1 Host...
I'm connected to vCenter and i executed the script...
I'm testing with another vCenter and keep you posted
did you change the code I posted at all? if so, can you post what you have?
No change, copy/past
Heh, forgot to -Append
foreach ($vmhost in $hostlist){
$vmhostname = $vmhost.name
$esxcli = Get-esxcli -VMHost $vmhost
$data = $esxcli.storage.core.path.list()
$data | Add-Member NoteProperty ESXi $vmhostname
$data | Export-Csv -path ..\Get_Local_Disks.csv -Append
}
As an alternative
ForEach-Object -Process {
$esxcli.storage.core.path.list.Invoke() |
Add-Member -MemberType NoteProperty -Name VMHost -Value $esxcli.VMHost.Name -PassThru
} | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD really this alternative is a good one
Thank you
Hi LuCD,
This is the report i am also looking but here the host is coming in the last column. Can we able to modify the columns as per the below order.
Host Name
Adapter
RuntimeName
Target
LUN
State
Device
Device Display Name
Regards
Narayanan.