script to update categories and projects | Nutanix Community
Skip to main content
Solved

script to update categories and projects

  • July 3, 2019
  • 1 reply
  • 1821 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 ?

Best answer by rhunt

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
Did this topic help you find an answer to your question?
This topic has been closed for comments

1 reply

rhunt
Forum|alt.badge.img+4
  • Trailblazer
  • 18 replies
  • Answer
  • July 15, 2019
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.