VMware Cloud Community
vin01
Expert
Expert
Jump to solution

need a script to get info of vms which are having raw map

Hi Guys

I need a script to get info of vms which are having raw map in the datacenter..

Like this

vm name

cluster name

esxi host ip

disk name..(if it is disk 1 or 2)

datastore name

nna

i used the below script but i am unable to get datastore name,cluster & host info

Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | fl

Please suggest any modified script to get above information..

Regards Vineeth.K
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | 
Get-HardDisk -DiskType "RawPhysical","RawVirtual" |
Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,
 
@{N="Datastore";E={$_.Filename.Split(']')[0].TrimStart('[')}},
 
@{N="VMHost";E={$_.Parent.Host.Name}},
 
@{N="Cluster";E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}}


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

View solution in original post

8 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | 
Get-HardDisk -DiskType "RawPhysical","RawVirtual" |
Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,
 
@{N="Datastore";E={$_.Filename.Split(']')[0].TrimStart('[')}},
 
@{N="VMHost";E={$_.Parent.Host.Name}},
 
@{N="Cluster";E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}}


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

vin01
Expert
Expert
Jump to solution

thanks LucD..its worked..

Regards Vineeth.K
Reply
0 Kudos
vin01
Expert
Expert
Jump to solution

Hi Luc

looking for IP address also..Can you correct the below code.its not writing IP

Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" |Select @{N="VMName";E={$_.Parent}},

#@{N='IP';E={[string]::Join(',',($_.Guest.IPAddress | Where {($_.Split(".")).length -eq 4}))}},

@{N="IP";E={[string]::Join(',',$_.Guest.IpAddress)|Where {($_.Split(".")).length -eq 4}}},

@{N="HardDisk";E={$_.Name}},

DiskType,

ScsiCanonicalName,

DeviceName,

@{N="Datastore";E={$_.Filename.Split(']')[0].TrimStart('[')}},

@{N="VMHost";E={$_.Parent.Host.Name}},

@{N="Cluster";E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}}

Regards Vineeth.K
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" |

Select @{N="VMName";E={$_.Parent}}, 

    @{N="IP";E={[string]::Join(',',($_.Parent.Guest.IpAddress|Where {$_.Split(".").length -eq 4}))}}, 

    @{N="HardDisk";E={$_.Name}}, 

    DiskType, 

    ScsiCanonicalName, 

    DeviceName, 

    @{N="Datastore";E={$_.Filename.Split(']')[0].TrimStart('[')}}, 

    @{N="VMHost";E={$_.Parent.Host.Name}}, 

    @{N="Cluster";E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}}  


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

vin01
Expert
Expert
Jump to solution

Thanks guru that works perfectly.

Regards Vineeth.K
Reply
0 Kudos
baburaju
Contributor
Contributor
Jump to solution

Hi LucD / Vineeth,

Thanks for this script, As I am looking for this info only.

A small question on this.

If I want to get along with raw map devices, other devices (i.e hard disks not ram mapped) which are mapped to VM. Then how can I get it using the script.

Thanks & Regards

Baburaju.

Reply
0 Kudos
vin01
Expert
Expert
Jump to solution

‌Try the code given below on my other thread.,In that code you will get complete vm information.

Complete VM information

Regards Vineeth.K
Reply
0 Kudos
baburaju
Contributor
Contributor
Jump to solution

HI Vineeth,

Thanks for the script its working fine for me

With regards

Babu raju.

Reply
0 Kudos