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:
Goal:
Creation of Virtual Networks
Seven internal virtual switches are created for lab networking:
This setup partitions different network segments for the VM.
Variable Setup and Archive Extraction
Recommended by LinkedIn
VM Import and Compatibility Report
Post-Import Configuration
Network Adapter Configuration
Connecting Network Adapters to Virtual Networks
Each of the 8 network adapters is connected to the previously created virtual switches as follows:
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
How to get the source file ?
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!