— Virtual and software defined stuff. And more! —

Leave a comment

Unmount datastore from all hosts without scripting

VMware_iconDo you want to remove (unmount) a datastore from all hosts in your VMware vSphere Environment without scripting or fixing all your hosts manually (and slowly)?
Start your vSphere Client and switch to the Datastores and Data clusters view. Expand the tree and find the datastore. Right click it and choose Delete and boom, this dialogue shows where you can select which hosts you want to remove the datastore from.


I´m almost embarassed that I haven´t seen this function earlier but it´s there (in vSphere 5.5 anyway) and it´s really neat.


Unfortunately, if you want to add datastores you have to do it host by host so now is the time to browse your script folder. Or you can use this one. Copy to a text file, name it something like “add_datastores.ps1” and run through powercli.


Connect-VIServer your_vcenter

$vmhosts = Get-VMHost -Location your_cluster

foreach ($vmhost in $vmhosts)


New-Datastore -VMHost $vmhosts -NFS -Name datastore_name -Path “/vol/volume/qtree” -NfsHost x.x.x.x