Book Image

Learning PowerCLI for VMware VSphere

By : Robert van den Nieuwendijk
Book Image

Learning PowerCLI for VMware VSphere

By: Robert van den Nieuwendijk

Overview of this book

Table of Contents (17 chapters)
Learning PowerCLI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Removing datastores


To remove a datastore, you can use the Remove-Datastore cmdlet. The syntax of this cmdlet is as follows:

Remove-Datastore [-Datastore] <Datastore[]> [-VMHost] <VMHost> [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm][<CommonParameters>]

The required parameters of the Remove-Datastore cmdlet are -Datastore and -VMHost.

In the next example, we will remove the Cluster01_Vmfs01 datastore, which we created at the beginning of this chapter:

PowerCLI C:\> Remove-Datastore -Datastore Cluster01_Vmfs01 -VMHost 192.168.0.133 -Confirm:$false

If you try to remove a datastore, it is possible that you get an error message similar to the following error message:

Remove-datastore : 1/18/2014 7:37:46 PM    Remove-Datastore   The resource '51ceb90c-6cb03821-3504-ac162daa6ca0' is in use.

Before you can remove a datastore, there are some requirements that must be fulfilled:

  • There must be no virtual machines residing on the datastore

  • The datastore must not be...