A set of functions to allow you to unmount/mount and detach/attach datastores from multiple hosts.

 

List all datastores and their mount/detach status by passing your datastore object(s) into the Get-DatastoreMountInfo advanced function as shown below:

 

List.jpg

 

To unmount a datastore pass your datastore object(s) to the Unmount-Datastore advanced function as seen below, this will unmount the datastore from all attached hosts:

 

Unmount.jpg

 

Once unmounted you will then be able to detach the datastore from the hosts using the Detach-Datastore cmdlet as shown below:

 

Detach.jpg


Script download

https://communities.vmware.com/servlet/JiveServlet/download/18008-1-78898/DatastoreFunctions.txt

 

Forward from

https://communities.vmware.com/docs/DOC-18008