hi guys
please am trying to fetches all eligible disks (unclaimed) info that can be utilized to create a VSAN disk
group.
and should also be able to fetch info of all the eligible disks in vcenter with details
including Canonical Name of disk, linked Hosts.
below is the required output i wish to get
Disk type (Cache disk/ Capacity disk),
• Drive type( Flash / HDD),
• canonical name of the disk
• cluster name linked to.
• Host it is linked with.
Have a look at the PowerCLI Cookbook for VSAN, more specifically page 34.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
When you are looking for eligible disks, there is no indication of Cache or Capacity yet.
That is only available for disks that are already used for VSAN.
You can test the IsSsd property and return the desired text.
For example, in a calculated property you could do
Get-VMHost -Name $VMHost |
Get-VMHostHba | Get-ScsiLun |
Where-Object { $_.VsanStatus -eq "InEligible" } |
Select CanonicalName,CapacityGB,MultipathPolicy,
@{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do
Get-Cluster -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
Get-VMHostHba | Get-ScsiLun |
Where-Object { $_.VsanStatus -eq "Eligible" } |
Select @{N='Cluster';E={$cluster.Name}},
@{N='VMHost';E={$esx.Name}},
CanonicalName,CapacityGB,MultipathPolicy,
@{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you LuCD, but this was what i meant Can you please rework it so that it should be able filter on ESXI host or cluster level. Module should be able to print the unclaimed disks only for that given input cluster or esxi hosts. and also
i should be able to print all the invocation in the artefact output
I have no clue what "artefact output" means.
How does that look?
You can use a Name parameter on the Get-Cluster and Get-VMHost cmdlets, which would allow you to limit the output.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have a look at the PowerCLI Cookbook for VSAN, more specifically page 34.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you so much this was so helpful as i can now see most of the fields i needed, but my only problem is some of the other fields are not showing when i use
The DriveType is found in the IsSsd property.
Not sure what you mean by DiskType
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
on the isssd property is there a way i can select Disktype: (Cache disk/ Capacity disk)
and when i say drive type this is what i mean: Drive type( Flash / HDD),
When you are looking for eligible disks, there is no indication of Cache or Capacity yet.
That is only available for disks that are already used for VSAN.
You can test the IsSsd property and return the desired text.
For example, in a calculated property you could do
Get-VMHost -Name $VMHost |
Get-VMHostHba | Get-ScsiLun |
Where-Object { $_.VsanStatus -eq "InEligible" } |
Select CanonicalName,CapacityGB,MultipathPolicy,
@{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you, this worked but am still finding challenges on how to know how to fetch all eligible disks (unclaimed) info using exsi and cluster.
You could do
Get-Cluster -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
Get-VMHostHba | Get-ScsiLun |
Where-Object { $_.VsanStatus -eq "Eligible" } |
Select @{N='Cluster';E={$cluster.Name}},
@{N='VMHost';E={$esx.Name}},
CanonicalName,CapacityGB,MultipathPolicy,
@{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you this really worked but it print all of the disk information i just needed it to print the one attached to a particular exsi_hostname, powercli print alot of information on the screen, i wanted to print my json output so it can display on an artefact so i can easily download is there a way i can do this in powercli?
Not sure what you mean by "to print my JSON output"?
To limit to a specific ESXi node, drop the Get-CLuster and use the Name parameter on the Get-VMHost cmdlet.
Get-VMHost -Name <MyEsx> -PipelineVariable esx |
Get-VMHostHba | Get-ScsiLun |
Where-Object { $_.VsanStatus -eq "Eligible" } |
Select @{N='VMHost';E={$esx.Name}},
CanonicalName, CapacityGB, MultipathPolicy,
@{N='Type';E={if($_.IsSsd){'Flash'}else{'HDD'}}} |
ConvertTo-Json
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you LuCD, but this was what i meant Can you please rework it so that it should be able filter on ESXI host or cluster level. Module should be able to print the unclaimed disks only for that given input cluster or esxi hosts. and also
i should be able to print all the invocation in the artefact output
I have no clue what "artefact output" means.
How does that look?
You can use a Name parameter on the Get-Cluster and Get-VMHost cmdlets, which would allow you to limit the output.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I WANT AN OUTPUT LIKE THIS
{ "results": { "disk info": [ { "six hostname": "10.10.10.220", "disks": { "disk1": { "disk type": "Capacity", "drive type": "Flash", "canonical name": "t10.ATA__MZ7L3480HCHQAD3________________S6NANA0W401440", "claim state": "ineligible", "cluster": "test cluster" }, "disk2": { "disk type": "Cache", "drive type": "HDD", "canonical name": "t10.ATA__MZ7L3480HCHQAD3________________S6NANA0W40006A", "claim state": "unclaimed", "cluster": "test cluster" } } }, { "six": "1.2.3.4.5", "disks": { "disk1": { "Disk type": "Capacity", "drive type": "Flash", "canonical name": "t10.ATA__MZ7L3480HCHQAD3________________S6NANA0W401XXX", "claim state": "ineligible", "cluster": "test cluster" }, "status message": "Disk Info has been fetched Successfully.", "timestamp": "Thu Apr 20 14:58:07 UTC 2023" }, "return code": 0, "invocation": { "vSphere hostname": "vcenter.gridirontest.com" } }