Syntax
Get-Datastore [-Server <VIServer[]>] [-Id <String[]>] [[-Name] <String[]>] [-Datacenter <Datacenter[]>] [-VMHost <VMHost[]>] [-VM <VirtualMachine[]>] [-Entity <VIObject[]>] [-Refresh] [<CommonParameters>]Related Commands
Online versionDetailed 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
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Name | String[] | Specify the names of the datastores you want to retrieve. | false | false | |
| Datacenter | Datacenter[] | Specify datacenters to filter the datastores associated with them. | false | true (ByValue) | |
| Entity | VIObject[] | Use this parameter to retrieve only the datastores used by at least one of the specified inventory objects. | false | false | |
| Id | String[] | Specify the Ids of the datastores you want to retrieve. | false | false | |
| Refresh | SwitchParameter | Indicates that the cmdlet first refreshes the storage system information and then retrieves the specified datastores. | false | false | |
| Server | VIServer[] | 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. | false | false | |
| VM | VirtualMachine[] | Specify virtual machines to filter the datastores used by at least one of them. | false | true (ByValue) | |
| VMHost | VMHost[] | Specify hosts to filter the datastores used by at least one of them. | false | true (ByValue) |
Return Type
DatastoreNotes
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.