PowerCLI Move-Datastore Function

Moving datastores into folders via drag/drop can be painful. In some cases vCenter does not want to allow a drag from a long list. Here is a quick function to make moving via PowerCLI a little bit easier.

Function Move-Datastore {
    param (
            $datastore = $(throw "Datastore(s) must be provided."),
            $folder = $(throw "A destination folder must be provided.")
    if ($folder.Type -ne "Datastore") {
        throw ("The specified folder is not a datastore folder.")
    $dsList = @()
    foreach ($ds in $datastore) {
        $dsList += $ds.ID

Comments (2)

  1. Michael

    Exactly what I need.

  2. Jg

    Hi, when i try to run the function i get this error, i am not very familiar with functions, can you assist with some pointers?
    Unable to find type [VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl[]]: make surly containing this type is loaded.

Leave a Comment

Your email address will not be published.