top of page
  • Rajeshkumar M

Copy NSX-T group's shell script

Automated copy of NSX-T local group to another NSX-T


#source and destination credentials







#get all groups from source NSX-T and filter with group name contains Sync text

for i in $(curl -k -s -X GET -u "$susername:$spassword" "https://$sfqdn/policy/api/v1/infra/domains/default/groups" | jq -r '.results[] | select(.id | index("Sync")) | .id')


echo $i

data=$(curl -k -s -X GET -u "$susername:$spassword" "https://$sfqdn/policy/api/v1/infra/domains/default/groups/$i" | jq '. | {expression,description,display_name}')

data=$(echo $data | jq 'del(.expression[].id) | del(.expression[].path) | del(.expression[].relative_path) | del(.expression[].parent_path) | del(.expression[].remote_path) | del(.expression[].marked_for_delete) | del(.expression[].overridden) | del(.expression[]._protection)')

#Copy the filtered groups to destination NSX-T

echo $data > out.txt

curl -k -s -X PATCH -u "$dusername:$dpassword" "https://$dfqdn/policy/api/v1/infra/domains/default/groups/copy-$i" -H "Accept: application/json" -H "Content-Type: application/json" -d @out.txt

echo "" > out.txt


20 views0 comments

Recent Posts

See All

vSphere Tags to NSX-T Tags

I created a simple powercli script to copy the vSphere Tags to NSX-T, it helped me to copy the NSX-T tags on the recovery VM's in non-federated/local NSX-T managers. Since SRM retain the vSphere TAG's

vIDM Locl user password reset without email link

When resetting config admin or any local user password in VMware identity manager will trigger an email link, if in case the smtp is not working/configured we can use API call to reset the password. Y

bottom of page