RSS

Tag Archives: datastore

Powershell: Batch removing datastores from ESXi hosts (4.1)

We have to repurpose a bunch of 10 ESXi host for another purpose and I need to remove all the 12 datastores already mounted on the hosts. Here is a one-liner which I used to remove datastores quickly using vsphere powershell CLI commands. Note hosts.txt and ds.txt contains a list of hosts and datastores which you want to remove. Broke down into paragraphs for readability, this should be a one-liner. This is for 4.1 hosts. 5.0 host and beyond may require a different command due to storage I/O controls.

get-content c:\scripts\hosts.txt |

% { $h = $_ ; get-content c:\scripts\ds.txt |

%{ "Host="+$h+" : Removing Datastore... "+$_ ;

remove-datastore -Datastore $_ -VMhost $h -confirm:$false}}

Advertisements
 
Leave a comment

Posted by on June 27, 2013 in powershell, Scripts, vmware

 

Tags: , ,