vSphere PowerCLI Reference

Get-Datastore

Synopsis

Retrieves the datastores available on a vSphere server.

Syntax

Get-Datastore [-Server <VIServer[]>] [-Id <String[]>] [[-Name] <String[]>] [-Datacenter <Datacenter[]>] [-VMHost <VMHost[]>] [-VM <VirtualMachine[]>] [-Entity <VIObject[]>] [-Refresh] [<CommonParameters>]

Related Commands

Online version
New-Datastore
Remove-Datastore
Set-Datastore

Detailed Description

Retrieves the datastores available on a vSphere server. 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.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
NameString[]Specify the names of the datastores you want to retrieve.falsefalse
DatacenterDatacenter[]Specify datacenters to filter the datastores associated with them.falsetrue (ByValue)
EntityVIObject[]Use this parameter to retrieve only the datastores used by at least one of the specified inventory objects.falsefalse
IdString[]Specify the Ids of the datastores you want to retrieve.falsefalse
RefreshSwitchParameterIndicates that the cmdlet first refreshes the storage system information and then retrieves the specified datastores.falsefalse
ServerVIServer[]Specify the vSphere servers 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
VMVirtualMachine[]Specify virtual machines to filter the datastores used by at least one of them.falsetrue (ByValue)
VMHostVMHost[]Specify hosts to filter the datastores used by at least one of them.falsetrue (ByValue)

Return Type

Datastore

Notes

Examples

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

Refreshes the host storage system and retrieves the datastores that are used by at least one of the specified virtual machines.


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