VMware Cloud Community
mamoth100
Contributor
Contributor

SRM Remove Protection

Looking for a way to remove protection from a deleted VM. When a VM is deleted out of vCenter, it goes into an invalid state In SRM.

I’m wondering if there is a way through PowerCLI to clean it up. I have a script to add protection using Meadowcroft’s module. I just don’t see a way with his cmdlets or the native SRM API to remove a VM from SRM if the actual VM is removed.

Thanks!

0 Kudos
8 Replies
LucD
Leadership
Leadership

Would the script attached to KB2032366 help?
It removes the managedBy tag from the VM.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
mamoth100
Contributor
Contributor

Thank you LucD!

Unfortunatly the VM object is removed from vCenter (completely deleted). So there isn’t a way to interact with the VM object like the script on that KB article states.

Was hoping there was a way to remove the invalid object in SRM like you would do by selecting the object in SRM and clicking Remove Protection. Thing is, with PowerCLI, to remove protection or add protection it seems to require you to get the VM object from vCenter and then pipe it to the add or remove protection cmdlets/API.

But since the VM is gone from vCenter, I don’t see a way to force a removal from SRM except to use the web interface to clear it.

0 Kudos
LucD
Leadership
Leadership

And the 2nd part of that KB where they clean up the vCenter DB?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
mamoth100
Contributor
Contributor

It wouldn't be the vCenter database. It would be the SRM database. Smiley Sad I just don't see that KB being valid since the cleanup needs to happen SRM side.

0 Kudos
sjesse
Leadership
Leadership

That kb is referencing the vcenter database, as those are vcenter related databases, its doing something similar by removing entries saying the vm is manged by something else.

0 Kudos
mamoth100
Contributor
Contributor

This issue being, that isn't what I'm trying to do. The VM in vCenter is deleted. So, it's no longer there. When you delete a VM from vCenter, SRM sees the delete and says "Invalid. The VM has been removed". So, I was looking for a way to remove that from SRM via PowerCLI.

The unprotect option seems to require me to do a Get-VM. But the VM is gone.

If I go into SRM, select the deleted VM, I can do a Remove Protection and that gets rid of that entry. No stopping the vCenter service. I was wondering how to do the same thing with PowerCLI.

0 Kudos
sjesse
Leadership
Leadership

I think you need to use the srm powercli commands like on this page https://automate-it.today/automating-srm-powercli/

#Get Protection group

$protectionGroups=$srmApi.Protection.ListProtectionGroups()

$targetProtectionGroup=$protectionGroups|where {$_.GetInfo().Name -eq$protgroup }

#Unprotect the VM

$protectTask=$targetProtectionGroup.UnprotectVms($vm.ExtensionData.MoRef)

while (-not$protectTask.IsComplete()) { sleep-Seconds1

Its a little out of date but I think the commands are correct. I'll see if I can come up with something later, but this might help someone else get something working quicker.

0 Kudos
mamoth100
Contributor
Contributor

Thank you so much! I will give it a go as well and report back!

0 Kudos