VMware Cloud Community
cmjellis
Enthusiast
Enthusiast
Jump to solution

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

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

3 Replies
LucD
Leadership
Leadership
Jump to solution

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

jpsider
Expert
Expert
Jump to solution

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
Jump to solution

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

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

 

Reply
0 Kudos