Managing the VMware datastore with PowerCLI (PowerShell)

In a VMware vSphere environment, a datastore is the basic building block for storage. You can use a few different types of datastores (such as NFS, iSCSI, or Fibre Channel), but they all do the same thing: they provide a means to store virtual machine data as well as other data.

For one-off tasks such as creating or removing a datastore in vSphere, a GUI is a fine choice, as it can easily guide the user. Although when it comes to bulk changes—for instance, adding 20 NFS datastores to each ESXi host—PowerCLI can save sysadmins hours of time and is a much better tool if you are working in a large environment.

For the sake of simplicities, I will be using NFS as my datastore type.

Creating a datastore

In PowerCLI, I must specify the VMhost, the name for the datastore, the path, and the NFS host when creating a new datastore:

As I alluded to earlier, typically you are going to want to add a datastore to all ESXi hosts at once. To create this datastore on all VMhosts in the cluster, I could use this command:

Read more on 4Sysops.com

Leave a Reply

Your email address will not be published. Required fields are marked *