DatastoreCluster

Moving a Datastore Cluster to a New Folder

We often get lots of interesting requests about figuring out how to automate something. The latest request was about how to move a datastore cluster between folders. This is the type of automation action which probably doesn’t need to be used all that often and is more aesthetic in nature than anything else. However, the interesting part is that, this request came from someone that found out they couldn’t perform the action in the UI. So, PowerCLI to the rescue!

Move-DatastoreCluster

PowerCLI doesn’t have a high-level cmdlet for this action, so we’ll be creating our own. To perform this action, we’ll be using a method that’s available in the vSphere API known as “MoveIntoFolder.” We can see some additional information about this method in the VMware Code API Explorer: MoveIntoFolder Method

I have created and shared a script on the PowerCLI Community repository and the VMware Code Sample Exchange which takes that “MoveToFolder” and wraps it in an advanced function we can call with: Move-DatastoreCluster

Example Usage

The script will need to be, what’s known as, dot sourced so that the advanced function is available in our current PowerShell session. From that point we will use the ‘DatastoreCluster’ parameter to pass a Datastore Cluster and the ‘Destination’ parameter to pass a folder.

Putting this altogether looks a bit like the following:
Move-DatastoreCluster Example Code

Summary

PowerCLI is a great tool to use when automating VMware environments. In the case of Datastore Clusters, we can actually use PowerCLI to perform tasks which aren’t available in the vSphere Client! The Move-DatastoreCluster script has been shared and presents an advanced function, of the same name, which allows us to move Datastore Clusters between the available folders.

If this is a function you’d like to see added to PowerCLI, head out to the public feature request site and upvote the following idea: Enhancement for moving inventory items Datastore Cluster

Comments

5 comments have been added so far

  1. Kami Menawarkan Promo – Promo JPCASH TERPECAYA
    dari banyak permainan
    seperti: poker, slot, bola, idn live game ….
    – Bonus New Member 50% All Game.
    – Bonus Next Deposit 5% All Game.
    – Bonus 10% CASHBACK Up TO Setiap Hari Selasa.
    – Min Deposit 25.000 & Min Withdraw Rp.50.000.
    – Depo & WD Terproses dengan Aman dan Cepat Hanya 3 Menit.
    Untuk Itu Mari Bergabung Bersama Kami Raih JUTAAN Rupiah Setiap Harinya Dan
    Berapa Pun Anda Menang Kami Pasti Akan Bayar
    Tanpa Ada Biaya Atw Potongan …………..

    Bisa Dengan Depo Pulsa Juga Lho …
    Minimal Depo Hanya Rp. 10.000
    Tanpa Ada Potongan

    +62-878-3093-7943
    INI Y BOS KU NO WHATSAPPNY …???

  2. Just wanted to note that you need to use the Get-DatastoerCluster command to fill in the object $DSCluster and Get-Folder to fill in the object $DSClusterFolder. You can’t just use the Move-DatastoreCluster funciton with the strings for -DatastoreCluster and Destination. It will error out.

    A good 2.0 of the function would get this data from the strings 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *