powershellvmwarepowerclivcenter

Powershell Move-HardDisk cmd issue


I am working on a Powershell script to automate migration of a few hundreds of virtual disks of my vmware infrastructure and came up to an issue:

The parameter "-Confirm" from command Move-HardDisk (module VMware.VimAutomation.Core\13.3.0.24145081) is not working for me

So, the following command Move-HardDisk -HardDisk $disk -Datastore $datastore -StorageFormat Thin -Confirm has the same result as this command Move-HardDisk -HardDisk $disk -Datastore $datastore -StorageFormat Thin

It just keeps opening the popup for confirmation which is a really blocking point for me.

Documentation for the command

Thanks for reading and looking forward for your help


Solution

  • The -Confirm common switch parameter can be a bit counter-intuitive, because presence is it's default value - to suppress confirmation prompts, explicitly pass $false as an argument value, like so:

    Move-HardDisk -HardDisk $disk -Datastore $datastore -StorageFormat Thin -Confirm:$false