HPE OneView

Is there a way to do a bulk remove of networks with HP OneView?

Trusted Contributor

Is there a way to do a bulk remove of networks with HP OneView?

Peter had a tedious task question:




Was wondering if there is a way of doing a bulk remove of networks on HP OneView  without going through the tedious task of removing one by one in the OneView console.




Input from Dung:




Hi Peter


You can either use the PowerShell library or Python Library for HP OneView




Example with PowerShell:

Get-HPOVNetwork | Remove-HPOVNetwork


Just want to share with you all the script we have developed.

So Peter had a challenge of deleting about 200 networks created in OneView. The networks' name have the following syntax

ChimPrv_A_x and ChimPrv_B_x where x is in the range of [400, 499]


So we come up with the following script:


400..499 | % {

                $A = $_.ToString(“ChimPrv_A_000”)   # String pattern ‘000’ is replaced by the number passed to the pipeline

                $B = $_.ToString(“ChimPrv_B_000”)

                Remove-HPOVNetwork –name $A –force –confirm:$false

                Remove-HPOVNetwork –name $B –force –confirm:$false


5 Lines to remove 200 networks!


Go , go learn PowerShell!




And from Chris:

There is no need for the .ToString() method. The int will be converted to string already if you were to specify the network name as "ChimPrv_A_$_" or "ChimPrv_B_$_" in your pipeline.




Suresh provided input:


  In my case I wanted to delete all the existing Ethernet networks (eg: in my case 39 Ethernet Networks), so achieved this through the following code snippet using PowerShell.


     $script:ethernetNetworksUri = "/rest/ethernet-networks"


   function deleteEthernetNetworks()


            $retVal = Send-HPOVRequest -uri $script:ethernetNetworksUri


            for ($i = 0; $i -lt $retVal.members.count; $i++)


                        $delEthUri = $retVal.members[$i].uri

                        $task = Send-HPOVRequest $delEthUri DELETE




I followed the same logic to delete the NetworkSets, LIG’s, Enclosure Groups, Enclosures, ServerProfile Templates, ServerProfiles, Storage Volumes etc.


And a reply from Chris:

The Remove-HPOV[resource] CMDLETs can support removing resources en-bulk via PowerShell’s native pipeline.  See the example for Remove-HPOVNetwork.