VMware Cloud Community
CenturaBro
Enthusiast
Enthusiast
Jump to solution

VMDK output showing naa ID

looking to find a way to shoot an output that shows

VMDK         SCSI ID of VMDK           Datastore VMDK Resides on               Underlying naa ID of that datastore (1 path)

I can get most of the information with one command but the naa ID is only obtainable through a get-scsilun to my knowledge.  I tried to dig through extensiondata in get-datastore | get-view but couldnt find anything useful.

any help would be appreciated.

thanks!

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VM -PipelineVariable vm | Get-HardDisk -PipelineVariable hd |

Select @{N='VM';E={$_.Parent.Name}},Name,

  @{N='SCSI-Id';E={

    $ctrl = $vm.ExtensionData.Config.Hardware.Device | where{$_.Key -eq $hd.ExtensionData.Controllerkey}

    "$($ctrl.BusNumber):$($hd.ExtensionData.UnitNumber)"

  }},

  @{N='DS';E={

    $script:ds = Get-View -Id $hd.ExtensionData.Backing.Datastore

    $script:ds.Name

  }},

  @{N='CanonicalName';E={$script:ds.Info.Vmfs.Extent[0].DiskName}}


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

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VM -PipelineVariable vm | Get-HardDisk -PipelineVariable hd |

Select @{N='VM';E={$_.Parent.Name}},Name,

  @{N='SCSI-Id';E={

    $ctrl = $vm.ExtensionData.Config.Hardware.Device | where{$_.Key -eq $hd.ExtensionData.Controllerkey}

    "$($ctrl.BusNumber):$($hd.ExtensionData.UnitNumber)"

  }},

  @{N='DS';E={

    $script:ds = Get-View -Id $hd.ExtensionData.Backing.Datastore

    $script:ds.Name

  }},

  @{N='CanonicalName';E={$script:ds.Info.Vmfs.Extent[0].DiskName}}


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

CenturaBro
Enthusiast
Enthusiast
Jump to solution

That pretty much does it. Really appreciate it!

Didn't know you could find the Extent under the get-harddisk cmdlet.

quick question,

if i want to find out more about all the API's under a command like get-datastore | get-view, is there a place i can go?

If i had a place to find Info.vmfs.Extent.DiskName for canonical I probably would have gotten it without having to ask a question.

Only way i do that now is through creating a variable and just drilling down through the cmdlet to see what it returns and hope I can find it.

the powercli reference sites ive found don't really drill down that deep

0 Kudos
LucD
Leadership
Leadership
Jump to solution

There is the API Reference, but that is not really bedside reading :smileygrin:

Start perhaps with the vSphere Web Services SDK Programming Guide.
And look at and explore examples.


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

0 Kudos