This PowerShell script automates importing and configuring an AudioCodes SBC VM on a Windows system with Hyper-V installed.

This PowerShell script automates importing and configuring an AudioCodes SBC VM on a Windows system with Hyper-V installed.

It creates necessary virtual networks, extracts the SBC VM image, imports and renames the VM, configures CPU, COM port, network adapters, VLANs, and connects them to virtual switches—all using PowerShell commands only.

Overview of the Script

Assumptions:

  • Windows Pro/Enterprise version 8.1, 10, 11 or Windows Server 2016–2025 with Hyper-V installed.
  • You have a trial version of the SBC VM image archived as a ZIP file.

Goal:

  • Import the SBC VM.
  • Configure the VM and associated virtual networks entirely via PowerShell.

Creation of Virtual Networks

Seven internal virtual switches are created for lab networking:

  • LAN 1 to LAN 5
  • OAMP (likely management)
  • WAN

This setup partitions different network segments for the VM.

Variable Setup and Archive Extraction

  • $SBCName is set as the VM name.
  • Paths for storing VM files and handling the archive are defined.
  • The script checks if the archive is already expanded; if not, it extracts the zip to the destination folder.

VM Import and Compatibility Report

  • The XML configuration of the VM is located.
  • Compare-VM generates a compatibility report, allowing safe import and auto-generating new VM IDs.
  • Problematic virtual network adapters identified in the report are disconnected to avoid errors.
  • Importing the VM uses this report to ensure compatibility.

Post-Import Configuration

  • The VM is renamed to $SBCName.
  • The VM processor is set to 2 virtual CPUs.
  • A virtual COM port is enabled, facilitating communication with the VM.

Network Adapter Configuration

  • The first two existing VM network adapters are renamed to "GE_1" and "GE_2".
  • Six additional virtual network adapters (GE_3 to GE_8) are added to the VM for expanded network interfaces.
  • VLAN trunking is configured on GE_6 and GE_7 adapters with allowed VLAN IDs 1002 and 1003.

Connecting Network Adapters to Virtual Networks

Each of the 8 network adapters is connected to the previously created virtual switches as follows:

  • GE_1 → LAN 1
  • GE_2 → LAN 2
  • GE_3 → LAN 3
  • GE_4 → LAN 4
  • GE_5 → LAN 5
  • GE_6 → OAMP
  • GE_7 → OAMP
  • GE_8 → WAN

Summary

This script provides a fully automated PowerShell method to bring up an SBC VM with multiple network interfaces configured, supporting VLANs and virtual COM communication. It is designed for environments with Hyper-V-enabled Windows versions and streamlines the manual setup of a complex VM lab environment.


Created by SBC Geek as an example of the first challenge result. Enjoy!

# Assumption 1: You already have a Windows Pro/Ent 11/10/8.1 or Windows Server 2025/2022/2019/2016
# Assumption 2: The Hyper-V role is successfully installed on the server
# Assumption 3: You already have a trial version of the Hyper-V VM SBC image

# The goal: Importing the SBC VM and setting the SBC VM in PowerShell only

# Creating lab networks
New-VMSwitch -name "LAN 1" -SwitchType Internal
New-VMSwitch -name "LAN 2" -SwitchType Internal
New-VMSwitch -name "LAN 3" -SwitchType Internal
New-VMSwitch -name "LAN 4" -SwitchType Internal
New-VMSwitch -name "LAN 5" -SwitchType Internal
New-VMSwitch -name "OAMP"  -SwitchType Internal
New-VMSwitch -name "WAN"   -SwitchType Internal

# Required Variables
$SBCName = "SBC1"
$DestPath = "D:\SBC\"
$SourceArchive = "E:\SBC\sbc-F7.60A.100.022-hyperv.zip"

# Intermediate variables and steps
$SourcePath = $DestPath + "\" + (Get-Item $SourceArchive).Basename
$SourceVMName = (Get-Item $SourceArchive).Basename -replace "-hyperv$",""
$VhdDestinationPath =  ($DestPath + $SBCname)
$SmartPagingFilePath = ($DestPath + $SBCname)
$SnapshotFilePath =    ($DestPath + $SBCname)
$VirtualMachinePath =  ($DestPath + $SBCname)
if (Test-Path -Path $SourcePath -PathType Container) {
    Write-Host "The folder already exists!"
} else {
    Expand-Archive $SourceArchive -DestinationPath $SourcePath
}

# The first one is importing SBC VM w/o errors
$vmconfig = get-item ($SourcePath + "\Virtual Machines\*.xml") | select -ExpandProperty Fullname
$report = Compare-VM `
-Path $vmconfig `
-Copy `
–GenerateNewID `
-SmartPagingFilePath $SmartPagingFilePath `
-SnapshotFilePath $SnapshotFilePath `
-VirtualMachinePath $VirtualMachinePath `
-VhdDestinationPath $VhdDestinationPath
# $report
# $report.Incompatibilities | Format-Table –AutoSize
$report.Incompatibilities[0].Source | Disconnect-VMNetworkAdapter
$report.Incompatibilities[1].Source | Disconnect-VMNetworkAdapter
Import-VM -CompatibilityReport $report

# The second one is renaming SBC VM
Rename-VM $SourceVMName -NewName $SBCName

# The third one is adding the second CPU and turning on the Virtual Communication Port
Set-VMProcessor -VMname $SBCName -count 2 -Reserve 0
Set-VMComPort -VMName $SBCName -Number 1 -Path ("\\.\pipe\" + $SBCName + "-ComPort")

# The fourth one is renaming 2 network adapters [PS only!!!]
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 0 | Rename-VMNetworkAdapter -NewName "GE_1"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 1 | Rename-VMNetworkAdapter -NewName "GE_2"

# The fourth one is adding 6 virtual network adapters to SBC VM with same names [Only available in PowerShell]
Add-VMNetworkAdapter -VMName $SBCName -Name "GE_3"
Add-VMNetworkAdapter -VMName $SBCName -Name "GE_4"
Add-VMNetworkAdapter -VMName $SBCName -Name "GE_5"
Add-VMNetworkAdapter -VMName $SBCName -Name "GE_6"
Add-VMNetworkAdapter -VMName $SBCName -Name "GE_7"
Add-VMNetworkAdapter -VMName $SBCName -Name "GE_8"

# The fifth one is assigning the VLANs to the two VM network adapters [Only available in PowerShell]
Set-VMNetworkAdapterVlan -VMName $SBCName -VMNetworkAdapterName "GE_6" -Trunk -AllowedVlanIdList "1002,1003" -NativeVlanId 0
Set-VMNetworkAdapterVlan -VMName $SBCName -VMNetworkAdapterName "GE_7" -Trunk -AllowedVlanIdList "1002,1003" -NativeVlanId 0
# Get-VMNetworkAdapterVlan -VMName $SBCName

# The sixth one is connecting all 8 VM network adapters to 7 desired Virtual Networks
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 0 | Connect-VMNetworkAdapter –SwitchName "LAN 1"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 1 | Connect-VMNetworkAdapter –SwitchName "LAN 2"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 2 | Connect-VMNetworkAdapter –SwitchName "LAN 3"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 3 | Connect-VMNetworkAdapter –SwitchName "LAN 4"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 4 | Connect-VMNetworkAdapter –SwitchName "LAN 5"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 5 | Connect-VMNetworkAdapter –SwitchName "OAMP"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 6 | Connect-VMNetworkAdapter –SwitchName "OAMP"
Get-VMNetworkAdapter -VMName $SBCName | Select -Index 7 | Connect-VMNetworkAdapter –SwitchName "WAN"
# Get-VMNetworkAdapter -VMName $SBCName        

Brilliant! I believe you should put it on GitHub…

You can't find this information in the AudioCodes documentation! It's just my experience and recommendations! Grab and use it!

To view or add a comment, sign in

More articles by SBC Geek: Exclusive Deep-Dive Expert Content from Massimiliano, Rizwan, Alex (improving his English)

Others also viewed

Explore content categories