Hyper-V Powershell Quick Tips SCVMM WAP Windows Server

SMA Runbook: SCVMM Logical Networks into HP OneView

This SMA Runbook will add any new or missing logical network definitions (i.e. VLAN’s) in SCVMM and to HP OneView appliance.

As well as having a “working SMA deployment”, the prerequisites for this Runbook are 5 SMA Variables (Assets) which are:



We use Active Directory to authenticate to our OneView. If you use local credentials you can remove this from the Runbook or set the variable to “Local”. Also a the login component of the runbook is a repeated task, instead of having multiple versions of code across multiple runbooks, I do recommend these become their own runbooks that is called upon like a function from each requiring workflow.


This will not modify any existing Network Sets or Logical Interconnect Groups, it simply adds the discovered network definition to HP OneView ready for being assigned to your Logical Interconnect Groups.

For adding networks to Logical Interconnects take a look at this script that uses the Rest API via PowerShell: http://blog.apps.id.au/?p=6291. That script has been generalized from a Runbook we use as part of our fabric management toolkit.


As with all content I share, please be vigilant and review before running on your environments.. i.e. use at your own risk 🙂

Note: the below has been modified from my production version but still works as expected

workflow Set-VMNetstoHPOV
    [string]$VMMServer = Get-AutomationVariable -Name 'VMMServer'
    [string]$OVAppliance = Get-AutomationVariable -Name 'HPOneViewAppliance'
    [string]$OVUsername = Get-AutomationVariable -Name 'HPOneViewUsername'
    [string]$OVPassword = Get-AutomationVariable -Name 'HPOneViewPassword'
    [string]$OVLoginDomain = Get-AutomationVariable -Name 'HPOneViewLoginDomain'
        $LICNets = @()
        $VMMNets = @()
        get-scvmmserver -computername $using:VMMServer | out-null
        if (-not (get-module HPOneview.300)) 
            Import-Module HPOneView.300
        if (-not $ConnectedSessions) 
            $ApplianceConnection = Connect-HPOVMgmt -Hostname $using:OVAppliance `
                -Username $using:OVUsername -Password $using:OVPassword `
                -AuthLoginDomain $using:OVLoginDomain
        # Get Networks from OneView
        Get-HPOVNetwork | ForEach-Object {$LICNets += $_.vlanid}
        $LICNets = $LICNets | get-unique
        # Get Networks from SCVMM
        Get-SCLogicalNetworkDefinition | ForEach-Object {$VMMNets += $_.Subnetvlans.VLanID}
        ForEach($VMMNet in $VMMNets)
                $diag = "VlanID:" + $VMMNet + " is not found in OneView... adding"
                Write-Output $diag
                $LNet = Get-SCLogicalNetworkDefinition | where {$_.subnetvlans.vlanid -match $VMMNet}
                New-HPOVNetwork -Type "Ethernet" -Name "$($LNet.LogicalNetwork.Name)_A" -VlanId $VMMNet -smartlink $true
                New-HPOVNetwork -Type "Ethernet" -Name "$($LNet.LogicalNetwork.Name)_B" -VlanId $VMMNet -smartlink $true



Leave a Reply

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