Solved

script to update categories and projects

  • 3 July 2019
  • 1 reply
  • 276 views

I have a bunch of VM (>300) converted from vmware, and I have to classify them with categories and projects.
I tried in powershell with the rest API, but when I GET the VM characteristics and use ConvertTo-Json to build new json file, it does not "expand" embedded arrays like disk_list, nic_list... so cannot send the PUT request correctly

Does someone have an example to set/update categories and project for a VM ?
icon

Best answer by rhunt 15 July 2019, 04:45

I don't have a current cluster to test projects with however I have ran into this before with PowerShell and long embedded Json. With your ConvertTo-Json specify the Depth switch and put 10.

code:
$var | ConvertTo-Json -Depth 10


That should at least expand your GET Json per vm so you can see all the options/body.
View original

This topic has been closed for comments

1 reply

Userlevel 1
Badge +1
I don't have a current cluster to test projects with however I have ran into this before with PowerShell and long embedded Json. With your ConvertTo-Json specify the Depth switch and put 10.

code:
$var | ConvertTo-Json -Depth 10


That should at least expand your GET Json per vm so you can see all the options/body.