- Run script in command prompt.
- In the C drive you will find a file P2V_IP_RECONFIG.TXT
- Now you can convert your vm
- Rename the nics to match the source vm
- Run the script file again.
- Now the nics will have their configurations set.
Problem: when you p2v a server it doesn’t keep it's nic configurations The new virtual nics are different nics so it doesn’t keep it's assignments.
If you have multiple nics, your problems multiplies.
The above thread showed me a script that dumps out your nic config/then readds the config to your virutalized server.
It requires SOME effort, because you have to rename the nics to match your old nics.
If you don’t the script throws an error.
Script is found here: http://www.rtfm-ed.co.uk/2008/06/26/reader-contribution-p2v-networking-script/
It's by Simon of autonation.com
How to Run the script:
Source VM:
Virtual VM
You will see the NICs have no configuration right?
*important*
The text file MUST be in c:\ , unless you modify the script.
The Script below : paste in VBS file
Option Explicit
'===> DECLARE CONSTANTS <===
Const HKEY_LOCAL_MACHINE = &H80000002
Const NETWORK_CONNECTIONS = &H31&
Const ForReading = 1
'===> DECLARE VARIABLES <===
Dim strComputer, objReg, i, j, arrAllInterfaces, arrIPs, strKeyPath, objShell, objFolder, objItem, colItems, Return, objFSO, objFile, strText, strCharacter, strNewCharacter, strNetConName
'===> VERIFY NIC CONFIGURTION FILE IS PRESENT <===
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\P2V_IP_RECONFIG.txt") Then
'===> DELETE OLD REGISTRY KEY FOR PHYSICAL NIC <===
strComputer = "."
strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
'Obtain array of all interfaces.
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrAllInterfaces
For i = 0 To UBound(arrAllInterfaces)
'Obtain array of IPs for each interface.
objReg.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & arrAllInterfaces(i), "IPAddress", arrIPs
'Iterate the IPs of each interface looking for non-zero.
'This should pick up all Interfaces that have an IP, as all
'other interfaces report "0.0.0.0" for the "IPAddress" value entry.
For j = 0 To UBound(arrIPs)
If arrIPs(j) <> "0.0.0.0" Then
objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath & "\" & arrAllInterfaces(i)
'WScript.Echo arrAllInterfaces(i)
End If
Next
Next
'===> GET NAME OF OLD NETWORK CONNECTION <===
Set objFile = objFSO.OpenTextFile("C:\P2V_IP_RECONFIG.txt", ForReading)
Do Until objFile.AtEndOfStream
strText = ""
strCharacter = objFile.Read(1)
If strCharacter = Chr(34) Then
Do Until objFile.AtEndOfStream
strNewCharacter = objFile.Read(1)
If strNewCharacter = Chr(34) Then
Exit Do
End If
If strNewCharacter <> "" Then
strText = strText & strNewCharacter
End If
Loop
Exit Do
End If
Loop
objFile.Close
'===> RENAME NETWORK CONNECTION <===
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)
Set colItems = objFolder.Items
For Each objItem in colItems
For i = 1 To 10
If objItem.Name = "Local Area Connection " & i Then
objItem.Name = strText
End If
Next
Next
Set objShell = Nothing
'===> IMPORT NIC CONFIGURATION USING NETSH<===
Set objShell = CreateObject("WScript.Shell")
Return = objShell.Run("%comspec% /c netsh exec c:\P2V_IP_RECONFIG.txt", 1, True)
'===> DELETE NIC CONFIGURATION FILE <===
objFSO.DeleteFile("c:\P2V_IP_RECONFIG.txt")
WScript.Echo "NIC Configuration completed."
'===> Destroy objects <===
Set objShell = Nothing
Set objFSO = Nothing
Else
'===> DUMP NIC CONFIGURATION USING NETSH ***
Set objShell = CreateObject("WScript.Shell")
Return = objShell.Run("%comspec% /c netsh interface ip dump>c:\P2V_IP_RECONFIG.txt", 1, True)
WScript.Echo "NIC CONfiguration has been saved."
End If
'===> DECLARE CONSTANTS <===
Const HKEY_LOCAL_MACHINE = &H80000002
Const NETWORK_CONNECTIONS = &H31&
Const ForReading = 1
'===> DECLARE VARIABLES <===
Dim strComputer, objReg, i, j, arrAllInterfaces, arrIPs, strKeyPath, objShell, objFolder, objItem, colItems, Return, objFSO, objFile, strText, strCharacter, strNewCharacter, strNetConName
'===> VERIFY NIC CONFIGURTION FILE IS PRESENT <===
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\P2V_IP_RECONFIG.txt") Then
'===> DELETE OLD REGISTRY KEY FOR PHYSICAL NIC <===
strComputer = "."
strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
'Obtain array of all interfaces.
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrAllInterfaces
For i = 0 To UBound(arrAllInterfaces)
'Obtain array of IPs for each interface.
objReg.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & arrAllInterfaces(i), "IPAddress", arrIPs
'Iterate the IPs of each interface looking for non-zero.
'This should pick up all Interfaces that have an IP, as all
'other interfaces report "0.0.0.0" for the "IPAddress" value entry.
For j = 0 To UBound(arrIPs)
If arrIPs(j) <> "0.0.0.0" Then
objReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath & "\" & arrAllInterfaces(i)
'WScript.Echo arrAllInterfaces(i)
End If
Next
Next
'===> GET NAME OF OLD NETWORK CONNECTION <===
Set objFile = objFSO.OpenTextFile("C:\P2V_IP_RECONFIG.txt", ForReading)
Do Until objFile.AtEndOfStream
strText = ""
strCharacter = objFile.Read(1)
If strCharacter = Chr(34) Then
Do Until objFile.AtEndOfStream
strNewCharacter = objFile.Read(1)
If strNewCharacter = Chr(34) Then
Exit Do
End If
If strNewCharacter <> "" Then
strText = strText & strNewCharacter
End If
Loop
Exit Do
End If
Loop
objFile.Close
'===> RENAME NETWORK CONNECTION <===
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)
Set colItems = objFolder.Items
For Each objItem in colItems
For i = 1 To 10
If objItem.Name = "Local Area Connection " & i Then
objItem.Name = strText
End If
Next
Next
Set objShell = Nothing
'===> IMPORT NIC CONFIGURATION USING NETSH<===
Set objShell = CreateObject("WScript.Shell")
Return = objShell.Run("%comspec% /c netsh exec c:\P2V_IP_RECONFIG.txt", 1, True)
'===> DELETE NIC CONFIGURATION FILE <===
objFSO.DeleteFile("c:\P2V_IP_RECONFIG.txt")
WScript.Echo "NIC Configuration completed."
'===> Destroy objects <===
Set objShell = Nothing
Set objFSO = Nothing
Else
'===> DUMP NIC CONFIGURATION USING NETSH ***
Set objShell = CreateObject("WScript.Shell")
Return = objShell.Run("%comspec% /c netsh interface ip dump>c:\P2V_IP_RECONFIG.txt", 1, True)
WScript.Echo "NIC CONfiguration has been saved."
End If
Pasted this script thanks to <http://www.rtfm-ed.co.uk/downloads/p2v_post_install_script.txt>
0 comments:
Post a Comment