Delete claimrules via PowerCLI

Had to mask storage in an older environment. As soon as that was done and storage were removed, then the clean up starts. I could have done all this by hand, but where is the fun in that. Instead I created this little script below which removes all claimrules with a rule number greater than 101 and lower than 65535. Of course this should go without saying. You need to know what you are doing and that there is no claimrules between 101-65535 that is crucial to your environment. Deleting claimrules like this shouldn’t be taking lightly.

Well, I had created all the claimrules my self with another script. So I was dead sure that deleting claimrules in this fashion would be no problem at all.


The script it self is simple. Change the $VMhosts variable to contain the hosts you need to do the clean up for. Then run the script. It will ask for a login to the hosts, usually that’s root. Then it connects to one host at a time and get a list of claimrules. Then the script loops through all claimrules and removes them nicely. Lastly when all rules on a host have been removed, it will rescan the HBA on the host. This will make sure that the host information around storage have been updated.

That is basically it and have a good day.



Leave a Reply

Your email address will not be published. Required fields are marked *