cmjellis
Enthusiast
Enthusiast

convert datastoreidlist to datastore

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)
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

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.

Carl_MTM
Contributor
Contributor

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

Note the command above needs the extra "}" at the end.

 

Reply
0 Kudos