Search

MachPanel Knowledgebase

INFO: Using Virtual Machine Import Utility

Mudesira Munir
MachPanel

Summary

This article provides information for using Virtual Machine Import Utility for importing VM's in MachPanel.

Applies To
This article applies to MachPanel build v8.2.50 Hf4 and above
Pre-requisites:

    1    At least one VM Service Plan should be created.
    2    The customer account should be present.
    3    Ensure the virtual machine is powered on before executing this operation.

Post-import tasks:
Verify and fix resources allocated to customer and reseller(Owner) according to actual usage.
Procedure

Please follow the below mentioned steps to bulk import VM's:

  • Open MachPanel Control Panel, log in as Provider and navigate to Home » Import Utilities » Virtual Machine. In step-1 provide the Import Settings as shown in the snapshot below



In Step-1, Yo have to select owner and the Hyper-V server. Under default settings:

  • For Client: Select customer.
  • Associate Service Plan: Select your hyper -v plan.
  • Subscription option: For multiple VM plan , you need to select one of the following:
    • Single Subscription for all VMs
    • Create Subscription for each VM
  • Operating System: Select image.
  • Subscription Start Date: It shows date
  • Billing cycle: Select billing cycle
  • Select Payment Group: Select currency
Select VM's to Import

  • In Step-2, you need to select the Virtual Machine you wish to import and associate them with the customer and service plan. You may select all VM's or import one-by-one.
  • Click on Next button.


Subscription Information

In Step-3, you have to select either new subscription or the existing one.

 

NIC Settings

Click on Manage button to configure NICs, click Continue import wizard, Click Finish. You need to specify "NIC setting" during import as shown below:

 

Note: Please note Network Adapter name should be different (in case there are more than on adapter). 

MachPanel creates adapters and identifies using "Name" of adapter. Please use below PowerShell script to automatically make NIC name unique for your desired VMs on a server as. We have already tested this in lab and found it to be working properly. The Script scans the VMs with duplicate NICs, asks you to conform if you want to make changes and then makes the Name Change.

Open "PowerShell ISE" as an Administrator and copy following script, then execute it:

#Requires -RunAsAdministrator
 
$VMs = Get-VM
 
foreach ($VM in $VMs) {
 
    Write-Host ""
    Write-Host "Checking VM: $($VM.Name)" -ForegroundColor Cyan
 
    $Adapters = @(Get-VMNetworkAdapter -VMName $VM.Name)
 
    # Find duplicate NIC names
    $DuplicateGroups = $Adapters |
        Group-Object -Property Name |
        Where-Object { $_.Count -gt 1 }
 
    if (-not $DuplicateGroups) {
        Write-Host "No duplicate NIC names found." -ForegroundColor Green
        continue
    }
 
    Write-Host ""
    Write-Host "Duplicate NIC names found in VM: $($VM.Name)" -ForegroundColor Yellow
 
    foreach ($Group in $DuplicateGroups) {
 
        Write-Host ""
        Write-Host "Duplicate Name: '$($Group.Name)'" -ForegroundColor Yellow
 
        $Group.Group |
            Select-Object Name, VMName, SwitchName, MacAddress |
            Format-Table -AutoSize
    }
 
    $Confirmation = Read-Host "Rename duplicate NICs in VM '$($VM.Name)'? (Y/N)"
 
    if ($Confirmation -notmatch '^[Yy]$') {
        Write-Host "Skipped VM: $($VM.Name)" -ForegroundColor DarkYellow
        continue
    }
 
    # Track all names already used in this VM
    $UsedNames = @{}
 
    foreach ($Adapter in $Adapters) {
        $UsedNames[$Adapter.Name.ToLowerInvariant()] = $true
    }
 
    foreach ($Group in $DuplicateGroups) {
 
        $OriginalName = $Group.Name
 
        # Keep the first adapter unchanged
        $AdaptersToRename = @(
            $Group.Group | Select-Object -Skip 1
        )
 
        $Counter = 2
 
        foreach ($Adapter in $AdaptersToRename) {
 
            # Find a genuinely unused name
            do {
                $NewName = "$OriginalName $Counter"
                $Counter++
            }
            while ($UsedNames.ContainsKey($NewName.ToLowerInvariant()))
 
            Write-Host ""
            Write-Host "Renaming specific NIC:" -ForegroundColor Magenta
            Write-Host "  Old Name : $($Adapter.Name)"
            Write-Host "  New Name : $NewName"
            Write-Host "  MAC      : $($Adapter.MacAddress)"
 
            # IMPORTANT:
            # Rename the exact adapter object, NOT by duplicate Name
            Rename-VMNetworkAdapter `
                -VMNetworkAdapter $Adapter `
                -NewName $NewName
 
            # Mark this new name as used
            $UsedNames[$NewName.ToLowerInvariant()] = $true
        }
    }
 
    Write-Host ""
    Write-Host "Completed VM: $($VM.Name)" -ForegroundColor Green
}
 
Write-Host ""
Write-Host "NIC duplicate-name scan and rename operation completed." -ForegroundColor Cyan
Details
Type: INFO
Level: Intermediate
Last Modified: Last Week
Last Modified By: zohaib.shaikh
Rated 5 stars based on 2 votes.
Article has been viewed 26K times.
Options
Also In This Category
Tags