cmjellis
Enthusiast
Enthusiast

convert datastoreidlist to datastore

Jump to solution

What syntax would i use to convert DatastoreIdList to datastore? i want to report the which datastore the vm has files on

get-vm cbsprtg01 | select Name, Datastore*

Name      DatastoreIdList
----      ---------------
cbsprtg01 {Datastore-datastore-15069, Datastore-datastore-260539}

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Try like this

Get-VM | select Name,

    @{N='Datastore';E={(Get-View -Id $_.DatastoreIdList -Property Name).Name -join ','}}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Try like this

Get-VM | select Name,

    @{N='Datastore';E={(Get-View -Id $_.DatastoreIdList -Property Name).Name -join ','}}


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

View solution in original post

0 Kudos
jpsider
Expert
Expert

What output do you want?

Get-VM $vm | select Name, @{N="Datastore";E={Get-Datastore -vm $_}

That will get you the same info without having to convert.