vSphere PowerCLI Reference



Retrieves the datastores available on a vSphere server.


Get-Datastore [-Server <VIServer[]>] [[-Name] <String[]>] [-Location <VIObject[]>] [-RelatedObject <DatastoreRelatedObjectBase[]>] [-Refresh] [<CommonParameters>]
Get-Datastore [-Server <VIServer[]>] -Id <String[]> [-Refresh] [<CommonParameters>]

Related Commands

Online version

Detailed Description

Retrieves the datastores available on a vCenter Server system. Returns a set of datastores that correspond to the filter criteria defined by the cmdlet parameters. To specify a server different from the default one, use the Server parameter.


NameTypeDescriptionRequired?Pipeline InputDefault Value
NameString[]Specify the names of the datastores you want to retrieve.falsefalse
IdString[]Specify the IDs of the datastores you want to retrieve.truefalse
LocationVIObject[]Specify vSphere container objects that you want to search for datastores. This parameter accepts Datacenter, Folder, and DatastoreCluster objects.falsefalse
RefreshSwitchParameterIndicates that the cmdlet first refreshes the storage system information and then retrieves the specified datastores.falsefalse
RelatedObjectDatastoreRelatedObjectBase[]Specify objects to retrieve one or more Datastore objects that are related to them. This parameter accepts vSphere VirtualMachine, VMHost, Datacenter, DatastoreCluster, and Folder objects, and vCloud Datastore objects.falsetrue (ByValue)
ServerVIServer[]Specify the vCenter Server systems on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse

Return Type




-------------- Example 1 --------------

Get-VMHost -Name VMHost1, VMHost2 | Get-Datastore

Retrieves datastores from the VMHost1 and VMHost2 hosts.

-------------- Example 2 --------------

Get-Datastore MainDatastore* -Datacenter Datacenter1

Retrieves the datastores from the Datacenter1 datacenter that have names starting with MainDatastore.

-------------- Example 3 --------------

Get-Datastore -VM $vm1, $vm2

Gets the datastores for a specified array of virtual machines.

-------------- Example 4 --------------

Get-Datastore -VMHost $script:vmhost

Refreshes the host storage system and get its datastores.

Copyright © 1998 - 2012 VMware, Inc. All rights reserved.