Building on the post that Jeffrey Kusters did on removing protected objects from NSX-T that PKS has created, I needed to automate this process for an environment which had 100+ of these objects.

First, a tiny bit of background; VMware PKS makes it pretty easy to deploy applications via Kubernetes and deploy them securely – because NSX-T is integrated and each Kubernetes objects will be firewalled, load balancers and can use other networking services to expose itself to the end users.

The integration between PKS and NSX-T is fully automated, and PKS creates protected objects (logical switches, logical routers, firewall rules, load balancers, etc.) inside NSX-T to make sure that these cannot be mistakenly deleted by an administrator.

But, sometimes it happens that PKS needs to be refreshed (commonly in labs, where people like me like to break things. 🙂 ), where it’s no longer available to remove those protected objects.

You can delete those objects via the NSX API, but manually doing those for each object can be a pain.

So, I created a quick PowerShell script that looks for these PKS objects and offers to delete them.

Hope this helps! 



Here’s an example output:

Share the wealth!