Using Powershell To Work With HP OneView

I have been using HP OneView a lot lately in my day today.  I went threw a class recently onOneView administration. The class was great, along with the usual labs givinghands on with the software, there were also a couple modules that introduced meto a powershell module for OneView.

Here is a link to the latest OneView module in thePowershell Gallery

https://www.powershellgallery.com/packages/HPOneView.500/5.0.2152.1665

 

To install the module, open powershell as administrator

Run the following command

Install-Module HPOneView.500

There will be a question asking if you want ot install froma untrusted repository, I selected [A] Yes to ALL

Once the install is complete you are ready to go!

To start be sure to connect powershell to OneView. Examplebelow

Connect-HPOVMgmt "ip address orname"

Enter your user and password in the pop up box.

During the initial set up of OneView, adding Networks to the system can take a while with the web gui. Below is sample code I used to add a bunch of networks to my lab environment

########################################################################################################################################

#Create New Networks

 

New-HPOVNetwork -Name "ESXivMotion" -Type Ethernet -VlanId 110 -SmartLink $False

New-HPOVNetwork -Name "VLAN20-A" -Type Ethernet -VlanId 20 -SmartLink $False

New-HPOVNetwork -Name "VLAN20-B" -Type Ethernet -VlanId 20 -SmartLink $False

New-HPOVNetwork -Name "VLAN30-A" -Type Ethernet -VlanId 30 -SmartLink $False

New-HPOVNetwork -Name "VLAN40-A" -Type Ethernet -VlanId 40 -SmartLink $False

New-HPOVNetwork -Name "VLAN50-A" -Type Ethernet -VlanId 50 -SmartLink $False

New-HPOVNetwork -Name "VLAN60-A" -Type Ethernet -VlanId 60 -SmartLink $False

New-HPOVNetwork -Name "VLAN30-B" -Type Ethernet -VlanId 30 -SmartLink $False

New-HPOVNetwork -Name "VLAN40-B" -Type Ethernet -VlanId 40 -SmartLink $False

New-HPOVNetwork -Name "VLAN50-B" -Type Ethernet -VlanId 50 -SmartLink $False

New-HPOVNetwork -Name "VLAN60-B" -Type Ethernet -VlanId 60 -SmartLink $False

 

Next I used some of theses networks to create a Network set for my ESXi servers

 

########################################################################################################################################

#Create Network Set

$Network20B = Get-HPOVNetwork -Name "VLAN20-B" -Type Ethernet

$Network30B = Get-HPOVNetwork -Name "VLAN30-B" -Type Ethernet

$Network40B = Get-HPOVNetwork -Name "VLAN40-B" -Type Ethernet

 

New-HPOVNetworkSet -Name "Production Networks B" -Untagged Network "VLAN 20-B" -Networks $Network20B, $Network30B, $Network40B -TypicalBandwidth 2500 -MaximumBandwidth 10000

This is just a couple of the uses where using this powershell module will save you a lot of time. Below is a link to HP’s github where there are several more examples.

https://github.com/HewlettPackard/POSH-HPOneView/wiki