Unprotect VMs from Protection Domain NCLI

  • 5 June 2020
  • 3 replies

Badge +1

Hi there,

I have many PDs and inside these PDs I have many VMs. I want to be able to run NCLI (or the like) to unprotect VM’s using a wildcard if possible. Example:

ncli pd unprotect name=ProtectionDomain vm_name=VM*

Anyone have an idea on how to do this to unprotect machines by wildcard to remove a mass amount at once?


Best answer by Sergei Ivanov 23 June 2020, 15:12

View original

This topic has been closed for comments

3 replies

Userlevel 4
Badge +5

Hi Aaron,

unfortunately, the traditional wildcard will not work there. You can use the following for-loop as a workaround:

for i in $(ncli pd list name=<PD-NAME> | grep "VM Name" | grep "<PART-OF-VM-NAME>" | awk {'print $NF'}); do ncli pd unprotect name=<PD-NAME> vm-names=$i; done

Just replace the <PD-NAME> from in the command above with the name of the Protection Domain and replace <PART-OF-VM-NAME> with what you would write before the * as if you used the wildcard. For example, if you want to remove only the VMs from the PD that have “accounting” in their name, put “accounting” there.

I know it is not a beautiful solution and it is rather slow, but it works.

Badge +1

I think that is exactly what I am looking for actually...i will test this out. thank you!

Badge +1

works like a’re right, a bit slow, but it does what i want! thanks!!