Datastore Category | Vmware PowerCLI Reference

Datastore Category

Cmdlets are usually implemented around resource operations. The four basic operations are CREATE, READ, UPDATE and DELETE. This set of operations is known as CRUD. Most of the cmdlets support CRUD which are respectively cmdlets that start with the New/Get/Set/Remove cmdlet verbs but they also may have additional operations

Step 1: Retrieve a object by running a Get command

You can READ objects by using Get-Datastore cmdlet. See example below:

# Retrieves datastores from the VMHost1 and VMHost2 hosts.

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

Step 2 : Run commands from the CRUD group

You can CREATE objects by using New-Datastore cmdlet. See example below:

# Creates a VMFS datastore by specifying the file system type.

New-Datastore -VMHost $vmhost -Name Datastore -Path $scsiLun.CanonicalName -Vmfs -FileSystemVersion 3
You can UPDATE objects by using Copy-DatastoreItem cmdlet. See example below:

# Copies the contents of a datastore folder in a local folder.

Copy-DatastoreItem vmstore:\Datacenter\Storage1\MyVM\* c:\VMFolder\MyVM\
You can REMOVE objects by using Remove-Datastore cmdlet. See example below:

# Removes the Datastore datastore from the host.

Remove-Datastore -Datastore Datastore -VMHost 10.23.112.234 -Confirm:$false

Step 3: Explore More Related Commands:


Get-DatastoreCluster This cmdlet retrieves datastore clusters.
Move-Datastore This cmdlet moves datastores from one location to another.
New-DatastoreCluster This cmdlet creates a new datastore cluster.
Remove-DatastoreCluster This cmdlet deletes the specified datastore clusters.
Set-Datastore This cmdlet modifies the properties of the specified datastore.
Set-DatastoreCluster This cmdlet modifies the configuration of the specified datastore cluster.