PowerCLI

 View Only

 Migrate PVC via code

Mark Morsing's profile image
Mark Morsing posted Jul 15, 2025 06:48 AM

Hey guys

Not sure i hit the correct forum, but heres goes.
I currently have 1000+ Kubernetes PVCs running - and i don't have Tanzu itself.
I need to migrate all of these PVCs from their current datastores to another datastore, i can do it manually via the UI, but i can't bulk select so i have to do it 1 by 1, and as you can image, it'll take me roughly a million years to do.

I initially wanted to do it via Powershell but i've been unable to locate a way to actually do it, without breaking the PVC / CNS link.

I stumpled upon the following API - which should do what i want.
Virtual Infrastructure JSON API

https://{api_host}/sdk/vim25/{release}/vsan/CnsVolumeManager/{moId}/CnsRelocateVolume

But i can't figure out how to actually run it, i tried searching for it in the development center in the vCenter and i can't locate it there either.

So my question is.
Does anyone know how to actually run this command? And can they point me in the right direction?

My vCenter version is 8.0.3.00500

Thanks!

jpsider's profile image
jpsider

In the developer center, did you try to the code capture feature to see if it would spit out powershell?

If not, you will need to connect to the vCenter using powershell via REST. Then you will be able to issue a invoke-restmethod command to the API (with the required body).

Mark Morsing's profile image
Mark Morsing

Hello @jpsider

I tried using the developer center the action isn't recorded at all, it just returns blank.

I figured I'd end up having to use rest, but no where can i read what exactly i need to do, and i can't find the command in the command explorer, only on the dev site.
I tried asking GPT and even that returns with how little the commandlet is documented haha :|...