01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 | function Get-FreeScsiLun {
|
$esx
=
Get-VMHost
-Name
MyEsx
Get-FreeScsiLun
-VMHost
$esx
|
Format-List
Try like this
function Get-FreeScsiLun {
param (
[parameter(ValueFromPipeline = $true,Position=1)]
[ValidateNotNullOrEmpty()]
[VMware.VimAutomation.Client20.VMHostImpl]
$VMHost
)
process{
$storMgr = Get-View $VMHost.ExtensionData.ConfigManager.DatastoreSystem
$storMgr.QueryAvailableDisksForVmfs($null) | %{
$result = $_
$lun = $VMHost.ExtensionData.Config.StorageDevice.ScsiLun | Where{$_.CanonicalName -eq $result.CanonicalName}
$lunId = $VMHost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter | %{
$_.Target | %{$_.Lun | where {$_.ScsiLun -match $lun.key}}
}
New-Object PSObject -Property @{
VMHost = $VMHost.Name
CanonicalName = $_.CanonicalName
LunID = if($lunId){$lunId[0].Lun}else{'na'}
Uuid = $_.Uuid
CapacityGB = [Math]::Round($_.Capacity.Block * $_.Capacity.BlockSize / 1GB,2)
}
}
}
}
$esx = Get-VMHost -Name MyEsx
Get-FreeScsiLun -VMHost $esx | Format-List
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
vGeek: VMware Datastores inventory powercli
Try like this
function Get-FreeScsiLun {
param (
[parameter(ValueFromPipeline = $true,Position=1)]
[ValidateNotNullOrEmpty()]
[VMware.VimAutomation.Client20.VMHostImpl]
$VMHost
)
process{
$storMgr = Get-View $VMHost.ExtensionData.ConfigManager.DatastoreSystem
$storMgr.QueryAvailableDisksForVmfs($null) | %{
$result = $_
$lun = $VMHost.ExtensionData.Config.StorageDevice.ScsiLun | Where{$_.CanonicalName -eq $result.CanonicalName}
$lunId = $VMHost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter | %{
$_.Target | %{$_.Lun | where {$_.ScsiLun -match $lun.key}}
}
New-Object PSObject -Property @{
VMHost = $VMHost.Name
CanonicalName = $_.CanonicalName
LunID = if($lunId){$lunId[0].Lun}else{'na'}
Uuid = $_.Uuid
CapacityGB = [Math]::Round($_.Capacity.Block * $_.Capacity.BlockSize / 1GB,2)
}
}
}
}
$esx = Get-VMHost -Name MyEsx
Get-FreeScsiLun -VMHost $esx | Format-List
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you!