vin01
Expert
Expert

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

Jump to solution

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

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

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

vin01
Expert
Expert

thanks LucD..its worked..

Regards Vineeth.K
0 Kudos
vin01
Expert
Expert

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
0 Kudos
LucD
Leadership
Leadership

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

Thanks guru that works perfectly.

Regards Vineeth.K
0 Kudos
baburaju
Contributor
Contributor

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.

0 Kudos
vin01
Expert
Expert

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

Complete VM information

Regards Vineeth.K
0 Kudos
baburaju
Contributor
Contributor

HI Vineeth,

Thanks for the script its working fine for me

With regards

Babu raju.

0 Kudos