View Only
  • 1.  PowerCLI no longer moving VM to folder **UPDATED**

    Posted Feb 19, 2020 08:20 PM

    After further searching, I found this discussion answered by LucD.  (Move-VM doesn't work against new VCSA 6.7 instance )  His solution of using the current host as the destination host has resolved the errors.  Updated code directly below:

    foreach ($server in $servers){

        $vm = Get-VM | Where-Object {$ -contains "$($server).dr"}

        $vmhost = $vm | get-vmhost

        Move-VM -VM $vm -Destination $vmhost -InventoryLocation $clientfolder


    For the last couple months I have used a simple script to move VMs to different folders inside of vCenter and it has worked perfectly.  We recently upgraded our vCenter to 6.7 (Build 15129973) and now for some reason it errors against a random datastore in the environment.  My version of PowerCLI is 11.5.0 build 14912921, so I don't believe it is tied to the previous PowerCLI issues specific to build 6.7.  Below is my code and the new error:

    $servers = Get-Content ".\input\client.txt"

    $vcenter = ""

    $creds = get-credential -Message "Enter vCenter Credentials"

    $connection = Connect-VIServer $vcenter -Credential $creds

    $windowsfolder = Get-Folder -Type VM -Name Windows

    $clientfolder = $windowsfolder | Get-Folder -Type VM -Name client

    foreach ($server in $servers){

        $vm = Get-VM | Where-Object {$ -contains "$($server).dr"}

        Move-VM -VM $vm -InventoryLocation $clientfolder


    $connection = Disconnect-VIServer -Confirm:$false -Force

    The error that is now returning for all move attempts is:

    Move-VM : 2/19/2020 1:40:33 PM  Move-VM         The operation for the entity "server.DR" failed with the following message: "Unable to access the virtual machine configuration:

    Unable to access file [Datastore1]"

    At line:4 char:5

    +     Move-VM -VM $vm -InventoryLocation $clientfolder

    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [Move-VM], CannotAccessVmConfig

        + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

  • 2.  RE: PowerCLI no longer moving VM to folder **UPDATED**
    Best Answer

    Posted Feb 19, 2020 08:35 PM

    Can you try changing

    Move-VM -VM $vm -InventoryLocation $clientfolder


    Move-VM -VM $vm -Destination $vm.VMHost -InventoryLocation $clientfolder

  • 3.  RE: PowerCLI no longer moving VM to folder **UPDATED**

    Posted Feb 19, 2020 08:37 PM

    This is much more concise than my solution.  Thank you as always for your help!

  • 4.  RE: PowerCLI no longer moving VM to folder **UPDATED**

    Posted Feb 19, 2020 09:02 PM

    This is an 'issue' (at least for me).
    This is different behaviour than in previous PowerCLI versions.

    Might be worth to raise an SR, with the idea 'The more report it ...'.