VMware Cloud Community
sagar666
Enthusiast
Enthusiast

Powercli to find datastores in a cluster and find shared datastore

Hi,

I am looking out a powercli script. Please help me

1. List datastores in a cluster

2.List only shared data stores it may be NFS,ISCSI,FC,FCOE and Not local datastore.

Thanks

Tags (1)
13 Replies
Abby01
Enthusiast
Enthusiast

Hi,

Try,

get-datstore | where{$_.ExtensionData.Summary.MultipleHostAccess -eq ‘true’} | Select Name, Type | export-csv .\Multi-Host-Access.CSV

Abby

Reply
0 Kudos
LucD
Leadership
Leadership

I think you forgot the cluster part :smileygrin:

Get-Cluster -Name <MyCluster> | Get-Datastore | where{$_.ExtensionData.Summary.MultipleHostAccess}


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

sagar666
Enthusiast
Enthusiast

Hi Lucd,

I tried that option but i am not getting any output. Below is the details

PowerCLI C:\Users\vidyasagar\Documents> get-cluster -Name blr-clus | Get-Datast

re

Get-Datastore : The input object cannot be bound to any parameters for the comm

and either because the command does not take pipeline input or the input and it

s properties do not match any of the parameters that take pipeline input.

At line:1 char:43

+ get-cluster -Name blr-clus | Get-Datastore <<<<

    + CategoryInfo          : InvalidArgument: (BLR-CLUS:PSObject) [Get-Datast

   ore], ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.

   Cmdlets.Commands.GetDatastore

Get-Datastore : The input object cannot be bound to any parameters for the comm

and either because the command does not take pipeline input or the input and it

s properties do not match any of the parameters that take pipeline input.

At line:1 char:43

+ get-cluster -Name blr-clus | Get-Datastore <<<<

    + CategoryInfo          : InvalidArgument: (BLR-CLUS:PSObject) [Get-Datast

   ore], ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.

   Cmdlets.Commands.GetDatastore

Reply
0 Kudos
LucD
Leadership
Leadership

Can you first check if the Get-Cluster cmdlet is returning anything?

Just do a Get-Cluster on it's own.

Is the name you passed on your earlier call in the list of returned cluster objects?

If nothing is returned, are you connected to a vSphere server?

Do a $global:defaultviservers


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

Reply
0 Kudos
sagar666
Enthusiast
Enthusiast

Hi Lucd,

It is connected and I am able to fetch get-cluster output. But i dont know it listing two times.

PowerCLI C:\Users\vidyasagar\Documents> get-cluster

Name                           HAEnabled  HAFailover DrsEnabled DrsAutomationLe

                                          Level                 vel

----                           ---------  ---------- ---------- ---------------

BLR-CLUS                       False      1          False      FullyAutomated

LAB                            True       1          True       FullyAutomated

BLR-CLUS                       False      1          False      FullyAutomated

LAB                            True       1          True       FullyAutomated

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership

Do you perhaps have two connections listed in $global:defaultviservers?


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

Reply
0 Kudos
sagar666
Enthusiast
Enthusiast

Hi Lucd,

Yes it is showing two connections.

Thanks,

Vidya Sagar

Reply
0 Kudos
LucD
Leadership
Leadership

Close one of the connections, then try again.


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

Reply
0 Kudos
sagar666
Enthusiast
Enthusiast

Hi Lucd,

No luck

PowerCLI C:\Users\rest\Documents>  $global:defaultviservers

Name                           Port  User

----                           ----  ----

vcenter.rest.com       443   administrator@vsphere.local

PowerCLI C:\Users\vidyasagar\Documents> get-cluster | get-datastore

Get-Datastore : The input object cannot be bound to any parameters for the comm

and either because the command does not take pipeline input or the input and it

s properties do not match any of the parameters that take pipeline input.

At line:1 char:28

+ get-cluster | get-datastore <<<<

    + CategoryInfo          : InvalidArgument: (BLR-CLUS:PSObject) [Get-Datast

   ore], ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.

   Cmdlets.Commands.GetDatastore

Get-Datastore : The input object cannot be bound to any parameters for the comm

and either because the command does not take pipeline input or the input and it

s properties do not match any of the parameters that take pipeline input.

At line:1 char:28

+ get-cluster | get-datastore <<<<

    + CategoryInfo          : InvalidArgument: (LAB:PSObject) [Get-Datastore],

    ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.

   Cmdlets.Commands.GetDatastore

Reply
0 Kudos
LucD
Leadership
Leadership

Which PowerCLI version are you using?

Do a Get-PowerCLIVersion


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

Reply
0 Kudos
sagar666
Enthusiast
Enthusiast

Hi Lucd,

I am using below version

PowerCLI C:\Users\vidyasagar\Documents> Get-PowerCLIVersion

PowerCLI Version

----------------

   VMware vSphere PowerCLI 5.5 Release 1 build 1295336

---------------

Snapin Versions

---------------

   VMWare AutoDeploy PowerCLI Component 5.5 build 1262826

   VMWare ImageBuilder PowerCLI Component 5.5 build 1262826

   VMware License PowerCLI Component 5.5 build 1265954

   VMware VDS PowerCLI Component 5.5 build 1295334

   VMware vSphere PowerCLI Component 5.5 build 1295334

My vcenter server version is 6.x

Reply
0 Kudos
LucD
Leadership
Leadership

Can you upgrade PowerCLI?

Latest version is 6.3R1


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

Reply
0 Kudos
sagar666
Enthusiast
Enthusiast

Thanks a lot now it is working fine

Reply
0 Kudos