$hostName = @('R740N01.hci.lab','R740N02.hci.lab')
$managementLogicalSwitchName = 'management'
$mgmtLogicalSwitch = Get-SCLogicalSwitch -Name $managementLogicalSwitchName
$managementUPPName = 'S2D_Management_UPP'
$mgmtUplinkPortProfileSet = Get-SCUplinkPortProfileSet -Name $managementUPPName
$storageLogicalSwitchName = 'storage'
$storageLogicalSwitch = Get-SCLogicalSwitch -Name $storageLogicalSwitchName
$storageUPPName = 'S2D_Storage_UPP'
$storageUplinkPortProfileSet = Get-SCUplinkPortProfileSet -Name $storageUPPName
$standardMgmtSwitchName = 'Management'
$standardStorageSwitchName = 'Storage'
$mgmtNetworkConnectionName = 'NIC1'
$storageNetworkConnectionName = 'SLOT 1 PORT 1'
You must replace the values of the above variables based on your VMM and host configuration. For the last two variables, $mgmtNetworkConnectionName and $storageNetworkConnectionName, any one of the adapter port names used to create the standard VM switch on the host is good enough.
In case of fully-converged network configuration, you can ignore $storageNetworkConnectionName variable.
# Convert standard switch to logical switch
foreach ($host in $hostName)
{
$vmHost = Get-SCVMHost -ComputerName $host
# Management
$standardMgmtSwitch = Get-SCVirtualNetwork -Name $standardMgmtSwitchName |
Where-Object { $_.VMHost -eq $hostName[1] -and $null -eq $_.LogicalSwitch }
$mgmtNetworkAdapter = Get-SCVMHostNetworkAdapter |
Where-Object {
$_.VMHost -eq $host -and $_.ConnectionName -eq $mgmtNetworkConnectionName }
$jobId = (New-Guid).Guid
Set-SCVMHostNetworkAdapter -VMHostNetworkAdapter $mgmtNetworkAdapter `
-UplinkPortProfileSet $mgmtUplinkPortProfileSet `
-JobGroup $jobId
Set-SCVirtualNetwork -ConvertToLogicalSwitch `
-LogicalSwitch $mgmtLogicalSwitch `
-VirtualNetwork $standardMgmtSwitch `
-JobGroup $jobId
Set-SCVMHost -VMHost $vmHost -RunAsynchronously -JobGroup $jobId
# Storage
$standardStorageSwitch = Get-SCVirtualNetwork -Name $standardStorageSwitchName |
Where-Object { $_.VMHost -eq $host -and $null -eq $_.LogicalSwitch }
$storageNetworkAdapter = Get-SCVMHostNetworkAdapter |
Where-Object {
$_.VMHost -eq $hostName[1] -and $_.ConnectionName -eq $storageNetworkConnectionName }
$jobId = (New-Guid).Guid
Set-SCVMHostNetworkAdapter -VMHostNetworkAdapter $storageNetworkAdapter `
-UplinkPortProfileSet $storageUplinkPortProfileSet `
-JobGroup $jobId
Set-SCVirtualNetwork -ConvertToLogicalSwitch `
-LogicalSwitch $storageLogicalSwitch `
-VirtualNetwork $standardStorageSwitch `
-JobGroup $jobId
Set-SCVMHost -VMHost $vmHost `
-RunAsynchronously `
-JobGroup $jobId
}
The above example shows two nodes each with a non-converged network configuration (Management and Storage). In case of a fully-converged network configuration, the Storage switch conversion block can be removed.