VMware Cloud Community
John3579
Contributor
Contributor

Powercli Script for Getting Datastore info

Anyone have a script that will give me the hostname, datastore name, path and ip number in a one liner kind of thing

I know I can do get-vmhost | get-datastore  etc

but I need it to show the hostname as well, doing get-vmhost | select name | get-datastore 

returns an error -

 

Can anyone help.

 

Thanks.

 

Jason.

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

With the Select-Object in between, you change the type of object that is passed to Get-Datastore.
Not sure what you mean by Path?
For the other data

Get-VMHost -PipelineVariable esx | Get-Datastore |

Select @{N='VMhost';E={$esx.Name}},

   @{N='Datatsore';E={$_.Name}},

   @{N='Path';E={}},

   @{N='IP';E={(Get-VMHostNetworkAdapter -vmhost $esx -VMKernel).IP -join '|'}}


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

Reply
0 Kudos