VMware Cloud Community
thiag2011
Enthusiast
Enthusiast
Jump to solution

Unmount and Delete multiple datastore

Hi all,

I have a vcenter 6.0, hosting multiple vms.

I need to unmount and detach 100+ datastores to fulfil a storage decommission.

VMs are already migrated.

Am looking for  a script, that can check the pre-requisite, if pre-requisite passed, then unmount and delete the datastore.

Could someone help me in this regard, please.

Thankyou...

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ok, for the pre-requisites you could use the function I provided in Test If The Datastore Can Be Unmounted

To unmount a datastore you have to use the API methods or use the esxcli (see KB2004605) commands.

The API methods were packaged in functions by Alan, see Datastore Mount/Unmount Detach/Attach functions

The esxcli commands can be done through Get-EsxCli.

Both will work, the functions have the advantage that they will make sure the datastore is unmounted on all connected ESXi nodes.

With the esxcli commands you will have run these commands on each connected ESXi node.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

What kind of pre-requisite are you talking about?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

Hi Luc,

Prerequisite to unmount a datastore.

Like, checking if a vm exist, SIOC enabled,part of heartbeat ...

I need to do these prechecks for multiple datastores (100+) and then unmount and delete.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, for the pre-requisites you could use the function I provided in Test If The Datastore Can Be Unmounted

To unmount a datastore you have to use the API methods or use the esxcli (see KB2004605) commands.

The API methods were packaged in functions by Alan, see Datastore Mount/Unmount Detach/Attach functions

The esxcli commands can be done through Get-EsxCli.

Both will work, the functions have the advantage that they will make sure the datastore is unmounted on all connected ESXi nodes.

With the esxcli commands you will have run these commands on each connected ESXi node.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

Thanks a lot Luc,

I was able to convert your script to fetch information from multiple datastores,at the same time,  and it worked well.

Reply
0 Kudos