Script de configuration Hyper-V Server in depth : hvconfig


Encore plus fort que Windows Server Core Configurator (cf. http://blogs.technet.com/longhorn/archive/2008/10/09/outil-de-configuration-pour-windows-server-2008-core.aspx) voici le script de configuration disponible dans Microsoft Hyper-V Server 2008.

Fabrice a trouvé la config et surtout récupéré le script sur sa machine Microsoft Hyper-V Server 2008. Good Job  😉

La documentation http://www.microsoft.com/downloads/details.aspx?FamilyId=E1E111C9-FA69-4B4D-8963-1DD87804C04F&displaylang=en

Voici le script il est dans “%windir%system32en-UShvconfig.vbs” (de là à le réutiliser pour les installations core…)

‘——————————————-
‘ Copyright (c) Microsoft Corporation. All rights reserved.

‘ Version 1.0
‘ hvconfig.vbs – Configuration script used to setup a Hyper-V machine for remote configuration


‘——————————————-

const L_Msg001_Text  = “No IP address”
const L_Msg002_Text  = ”   No IP   “
const L_Msg003_Text  = “No active network adapters found.”
const L_Msg004_Text  = “Warning”
const L_Msg005_Text  = ”                           Hyper-V Configuration”
const L_Msg006_Text  = “1) Domain/Workgroup:   “
const L_Msg007_Text  = “2) Computer Name:   “
const L_Msg008_Text  = “3) Network Settings”
const L_Msg009_Text  = “4) Add Local Administrator”
const L_Msg010_Text  = “5) Windows Update Settings:  “
const L_Msg011_Text  = “6) Download and Install Updates: “
const L_Msg012_Text  = “7) Remote Desktop:   “
const L_Msg013_Text  = “8) Regional and Language Options”
const L_Msg014_Text  = “9) Date and Time”
const L_Msg015_Text  = “10) Log Off User”
const L_Msg016_Text  = “11) Restart Server”
const L_Msg017_Text   = “12) Shut Down Server”
const L_Msg018_Text   = “13) Exit to Command Line”
const L_Msg019_Text  = “Enter number to select an option: “
const L_Msg020_Text  = “Change Domain/Workgroup Membership”
const L_Msg021_Text  = “Join (D)omain or (W)orkgroup? (Blank=Cancel) “
const L_Msg022_Text  = “Domain”
const L_Msg023_Text  = “Workgroup”
const L_Msg024_Text  = “Machine currently joined to a domain.”
const L_Msg025_Text  = “Do you want to remove this computer from the current domain now?”
const L_Msg026_Text  = “Specify an authorized domainuser:  “
const L_Msg027_Text  = “Removing computer from current domain…”
const L_Msg028_Text  = “You must restart your computer to apply these changes.”
const L_Msg029_Text  = “Restart now?”
const L_Msg030_Text  = “Restart”
const L_Msg031_Text  = “Specify domainuser:  “
const L_Msg032_Text  = “Join Domain”
const L_Msg033_Text  = “Enter new computer name (Blank=Cancel): “
const L_Msg034_Text  = “Computer Name”
const L_Msg035_Text  = “Changing Computer name…”
const L_Msg036_Text  = “Enter account to join local Administrators group (Blank=Cancel): “
const L_Msg037_Text  = “Adding to local Administrators group…”
const L_Msg038_Text  = “Local Administrators Group” 
const L_Msg039_Text  = “User added to local Administrators group.”
const L_Msg040_Text  = “User not found.”
const L_Msg041_Text  = “User already in local Administrators group.”
const L_Msg042_Text  = “Failed to add user to local Administrators group.”
const L_Msg043_Text  = “Windows Update currently set to: “
const L_Msg044_Text  = “Select (A)utomatic or (M)anual updates: “
const L_Msg045_Text  = “Automatic”
const L_Msg046_Text  = “System will check for and install updates every day at 3:00 AM.”
const L_Msg047_Text  = “Enabling Automatic updates…”
const L_Msg048_Text  = “Manual”
const L_Msg049_Text  = “System will never check for updates.”
const L_Msg050_Text  = “Disabling Automatic updates…”
const L_Msg051_Text  = “Windows Update set to “
const L_Msg052_Text  = “Update Settings”
const L_Msg053_Text  = “(E)nable or (D)isable Remote Desktop? (Blank=Cancel) “
const L_Msg054_Text  = “1) Allow only clients running Remote Desktop with Network Level Authentication (more secure)”
const L_Msg055_Text  = “2) Allow clients running any version of Remote Desktop (less secure)”
const L_Msg056_Text  = “Enter selection: “
const L_Msg057_Text  = “Enabling Remote Desktop…”
const L_Msg058_Text  = “Remote Desktop enabled for clients running any version of Remote Desktop (less secure).”
const L_Msg059_Text  = “Remote Desktop”
const L_Msg060_Text  = “Remote Desktop enabled for clients only running Remote Desktop with Network Level Authentication (more secure).”
const L_Msg061_Text  = “Failed to disable Remote Desktop.”
const L_Msg062_Text  = “Disabling Remote Desktop…”
const L_Msg063_Text  = “Remote Desktop disabled.”
const L_Msg064_Text  = “Are you sure you want to log off?”
const L_Msg065_Text  = “Log Off”
const L_Msg066_Text  = “Are you sure you want to restart?”
const L_Msg067_Text  = “Are you sure you want to shut down?”
const L_Msg068_Text  = “Shut Down”
const L_Msg069_Text  = “Enabled (all clients)”
const L_Msg070_Text  = “Enabled (more secure clients only)”
const L_Msg071_Text  = “Disabled”
const L_Msg072_Text  = “——————————–”
const L_Msg073_Text  = ”    Network settings”
const L_Msg074_Text  = “Available Network Adapters”
const L_Msg075_Text  = “Index# IP address Description”
const L_Msg076_Text  = “Select Network Adapter Index# (Blank=Cancel):  “
const L_Msg077_Text  = ”    Network Adapter Settings”
const L_Msg078_Text  = “NIC Index”
const L_Msg079_Text  = “Description”
const L_Msg080_Text  = “IP Address”
const L_Msg081_Text  = “DHCP enabled”
const L_Msg082_Text  = “Preferred DNS Server”
const L_Msg083_Text  = “Alternate DNS Server”
const L_Msg084_Text  = “1) Set Network Adapter IP Address”  
const L_Msg085_Text  = “2) Set DNS Servers”
const L_Msg086_Text  = “3) Clear DNS Server Settings”
const L_Msg087_Text  = “4) Return to Main Menu”
const L_Msg088_Text  = “Select option:  “
const L_Msg089_Text  = “Select (D)HCP, (S)tatic IP (Blank=Cancel): “
const L_Msg090_Text  = “Set Static IP”
const L_Msg091_Text  = “Enter static IP address: “
const L_Msg092_Text  = “Enter subnet mask (Blank = Default “
const L_Msg093_Text  = “): “
const L_Msg094_Text  = “Enter default gateway: “
const L_Msg095_Text  = “Setting NIC to static IP…”
const L_Msg096_Text  = “The IP address could not be changed.”
const L_Msg097_Text  = “Network Settings”
const L_Msg098_Text  = “Setting NIC to use DHCP…”
const L_Msg099_Text  = “DNS Servers”
const L_Msg100_Text  = “Enter new preferred DNS server (Blank=Cancel): “
const L_Msg101_Text  = “Preferred DNS server set.”
const L_Msg102_Text  = “Enter alternate DNS server (Blank = none): “
const L_Msg103_Text  = “Alternate DNS server set.”
const L_Msg104_Text  = “Alternate DNS server could not be set.”
const L_Msg105_Text  = “Preferred DNS server could not be set.”
const L_Msg106_Text  = “DNS servers removed. DNS servers will be automatically obtained from network.”
const L_Msg107_Text  = “DNS servers could not be deleted.”
const L_Msg108_Text  = “Failed to join workgroup”
const L_Msg109_Text  = “Welcome to workgroup: “
const L_Msg110_Text  = “Unknown”
const L_Msg111_Text  = “Inspecting system…”
const L_Msg112_Text  = “Please specify a valid IP address.”
const L_Msg113_Text  = “IP addresses with 127 are not valid because they are reserved for loopback addresses. Please specify some other valid value between 1 and 223.”
const L_Msg114_Text  = “Access is denied.”
const L_Msg115_Text  = “The parameter is incorrect.”
const L_Msg116_Text  = “The system cannot open the specified object.”
const L_Msg117_Text  = “Unable to update the password.”
const L_Msg118_Text   = “Logon failure: unknown username or password.”
const L_Msg119_Text  = “The specified domain either does not exist or could not be contacted.”
const L_Msg120_Text  = “The account already exists.”
const L_Msg121_Text  = “The machine is already joined to the domain.”
const L_Msg122_Text  = “The machine is not currently joined to a domain.”
const L_Msg123_Text  = “Failed to join domain.”
const L_Msg124_Text  = “Name of domain to join:  “
const L_Msg125_Text  = “Name of workgroup to join:  “
const L_Msg126_Text   = “Joining “
const L_Msg127_Text   = “…”
const L_Msg128_Text  = “===============================================================================”
const L_Msg129_Text  = “E” ‘(E)nable
const L_Msg130_Text  = “D” ‘(D)isable
const L_Msg131_Text  = “S” ‘(S)tatic IP
const L_Msg132_Text  = “D”  ‘(D)HCP
const L_Msg133_Text  = “W” ‘(W)orkgroup
const L_Msg134_Text  = “D”  ‘(D)omain
const L_Msg135_Text  = “In a domain environment, specify domainusername.”
const L_Msg136_Text  = “In a workgroup environment, specify username.”
const L_Msg137_Text  = “M” ‘Manual
const L_Msg138_Text  = “A” ‘Automatic
const L_Msg139_Text  = “Subnet Mask”
const L_Msg140_Text  = “Default Gateway”
const L_Msg141_Text  = “Last manual check: “

const WUA_Script  = “cscript WUA_SearchDownloadInstall.vbs”

 

Dim CmdResults
Dim pcname
Dim group_type
Dim groupname
Dim InDomain
Dim MgmtNIC
Dim patching_status
Dim Autopatch
Dim Update_schedule
Dim objNetAdapter
Dim DNSsetting
Dim DisplayIP
Dim objWshScriptExec
Dim TS_status
Dim ResultsTitle

Set oShell = WScript.CreateObject (“WScript.shell”)
Set objWMIService = GetObject( “winmgmts:\.rootcimv2″)

‘Force to run with cscript
if Instr(1,Wscript.FullName,”Cscript”,vbTextCompare)=0 then
 oShell.Run “cscript ” & chr(34) & wscript.ScriptFullName & chr(34)
 wscript.quit
end if

GetInitialStatusValues()

Do

‘ Get NICs
Set nics = objWMIService.ExecQuery(“SELECT * FROM Win32_NetworkAdapterConfiguration where IPenabled=TRUE”)
 
‘ Try to select the first NIC with an active IP  
for each n in nics
 MgmtNIC= n.index
 Set objNetAdapter = GetObject(“winmgmts:Win32_NetworkAdapterConfiguration=” & MgmtNIC)
 exit for
next 
   
‘ Deal with case where NICs go away
if MgmtNIC=”” then
 ‘No active NIC
 DisplayIP = L_Msg003_Text
else
 Set objNetAdapter = GetObject(“winmgmts:Win32_NetworkAdapterConfiguration=” & MgmtNIC)
 
 if objNetAdapter.IPenabled then
  DisplayIP = objNetAdapter.IPAddress(0)
 else
  ‘No Active NICs
  DisplayIP = L_Msg003_Text
 end if 
end if

‘ Get Domain status
InDomain = GetDomainStatus()

‘ Get Remote Desktop status
CheckRemoteDesktop()

wscript.echo
wscript.echo L_Msg128_Text
wscript.echo L_Msg005_Text
wscript.echo L_Msg128_Text
wscript.echo
wscript.echo L_Msg006_Text & group_type &”:  ” & groupname
wscript.echo L_Msg007_Text & pcname

if MgmtNIC=”” then
 wscript.echo L_Msg008_Text & vbTab & vbTab & vbTab & DisplayIP
else
 wscript.echo L_Msg008_Text
end if

wscript.echo L_Msg009_Text
wscript.echo “”
wscript.echo L_Msg010_Text & Update_schedule
wscript.echo L_Msg011_Text & L_Msg141_Text & patching_status
wscript.echo L_Msg012_Text & TS_status
wscript.echo “”
wscript.echo L_Msg013_Text
wscript.echo L_Msg014_Text
wscript.echo “”
wscript.echo L_Msg015_Text
wscript.echo L_Msg016_Text
wscript.echo L_Msg017_Text
wscript.echo “”
wscript.echo L_Msg018_Text

For i=1 to 2
   wscript.echo
next

wscript.StdOut.Write L_Msg019_Text      
OptionSelection = Wscript.StdIn.ReadLine  

wscript.echo

Select Case OptionSelection
  
 Case “1” ‘Change Domain/workgroup name
 

  wscript.echo
  wscript.echo L_Msg020_Text

  do
  wscript.echo
  wscript.StdOut.Write L_Msg021_Text
  DorW = Wscript.StdIn.ReadLine

  ‘added ascw(DorW)=164 and ascw(DorW)=1072 to detect Russian character choice
  loop until ucase(DorW)=ucase(L_Msg134_Text) or ucase(DorW)=ucase(L_Msg133_Text) or DorW=”” or ascw(DorW)=164 or ascw(DorW)=1072

  if ucase(DorW)=ucase(L_Msg133_Text) or ascw(DorW)=1072 then
   ‘Join Workgroup
   ‘If in a domain, we need to remove it first before joining a workgroup
   if InDomain then
    confirm = msgbox(L_Msg024_Text & vbCRLF & L_Msg025_Text,VBYesNo,L_Msg004_Text)
    if confirm=vbYes then
     wscript.StdOut.Write L_Msg026_Text
     domainuser = Wscript.StdIn.ReadLine

     wscript.echo
     wscript.echo L_Msg027_Text
     
     targetstr = “netdom remove %computername% /domain:” & NewGroupName & ” /userd:” & domainuser & ” /passwordd:*”
     result= oShell.Run(targetstr,1,TRUE)
     
     if result=0 then
      confirm = msgbox(L_Msg028_Text & vbCRLF & L_Msg029_Text, VBYesNo,L_Msg030_Text)
      if confirm=vbYes then oShell.Run “shutdown /r /t 0″,1
     else
      DomainAccessErrorMsg(result)
     end if  
    end if
   else
    JoinWorkgroup()
   end if
   
   end if
   
   if ucase(DorW)=ucase(L_Msg134_Text) or ascw(DorW)=164 then 
    ‘Joining Domain
   group_type= L_Msg022_Text
   
   wscript.StdOut.Write L_Msg124_Text
   NewGroupName = Wscript.StdIn.ReadLine
  
   wscript.StdOut.Write L_Msg026_Text
   domainuser = Wscript.StdIn.ReadLine

   wscript.echo
   wscript.echo L_Msg126_Text & NewGroupName & L_Msg127_Text    
   
   targetstr = “netdom join %computername% /domain:” & NewGroupName & ” /userd:” & domainuser & ” /passwordd:*”
   
   result= oShell.Run(targetstr,1,TRUE)
   if result=0 then
    confirm = msgbox(L_Msg028_Text & vbCRLF & L_Msg029_Text, VBYesNo,L_Msg032_Text)
    if confirm=vbYes then oShell.Run “shutdown /r /t 0″,1
   else
    DomainAccessErrorMsg(result)      
   end if   
     
    end if

 
 Case “2” ‘Change Computer Name
  
  wscript.StdOut.Write L_Msg033_Text
  NewComputerName = Wscript.StdIn.ReadLine
  
  if NewComputerName<>”” then
      
   ResultsTitle= L_Msg034_Text   
   wscript.echo L_Msg035_Text
   wscript.echo
   
   if not InDomain then
    ‘In workgroup                
      Set objWshScriptExec = oShell.Exec(“netdom renamecomputer %computername% /force /NewName:” & NewComputerName)         
      DisplayCmdLineOutput()       
      result= objWshScriptExec.exitcode
   else
    ‘In Domain
      wscript.StdOut.Write L_Msg026_Text
      domainuser = Wscript.StdIn.ReadLine
      result = oShell.Run(“netdom renamecomputer %computername% /force /NewName:” & NewComputerName & ” /userd:” & domainuser & ” /passwordd:*”,1,TRUE)
      if result<>0 then
     DomainAccessErrorMsg(result)    
      end if
   end if
        
   if result=0 then
    confirm = msgbox(L_Msg028_Text & vbCRLF & L_Msg029_Text, VBYesNo,L_Msg030_Text)
    if confirm=vbYes then oShell.Run “shutdown /r /t 0″,1
   end if
   
  end if
  
 Case “3”  ‘Change Management NIC Assignment
  
  If MgmtNIC<>”” then 
   ManagementNICsettings()
  else
   ‘Display no active NIC message
   DisplayIP = L_Msg003_Text
   Msgbox DisplayIP,vbExclamation,L_Msg004_Text
  end if
  
 Case “4” ‘Add Account to local admin
 
  wscript.echo L_Msg135_Text
  wscript.echo L_Msg136_Text
  wscript.echo
  wscript.StdOut.Write L_Msg036_Text
  AddUserAcct = Wscript.StdIn.ReadLine
  if AddUserAcct=”” then
   ‘cancel 
  else   
   if not InDomain then
    ‘Handle workgroup case by creating account first
    targetstr = “net user ” & AddUserAcct & ” * /add”
    result= oShell.Run(targetstr,1,TRUE)           
   end if
  
   wscript.echo L_Msg037_Text
   targetstr= “net localgroup administrators /add ” & AddUserAcct   
   result= oShell.Run(targetstr,7,TRUE)  
   select case result
    Case 0
     msgbox L_Msg039_Text & vbCrLf & AddUserAcct,vbInformation,L_Msg038_Text 
    Case 1
     msgbox L_Msg040_Text & vbCrLf & AddUserAcct,vbCritical,L_Msg038_Text
    Case else
     msgbox L_Msg042_Text & vbCrLf & AddUserAcct,vbCritical,L_Msg038_Text 
   end select   
  end if

 Case “5” ‘Update Settings
 
  wscript.echo L_Msg043_Text & Update_schedule
  wscript.StdOut.Write L_Msg044_Text
  updateselection = Wscript.StdIn.ReadLine
  
  if ucase(updateselection)=ucase(L_Msg138_Text) then
   ‘Make updates automatic
   Update_schedule= L_Msg045_Text
   strSchedule= L_Msg046_Text
   wscript.echo
   wscript.echo L_Msg047_Text
   oShell.Run “Cscript %WinDir%System32SCregEdit.wsf /AU 4″ & NewComputerName,7,TRUE   
  end if
  
  if ucase(updateselection)=ucase(L_Msg137_Text) then  
      ‘Make updates manual
   Update_schedule= L_Msg048_Text
   strSchedule= L_Msg049_Text
   wscript.echo
   wscript.echo L_Msg050_Text
   oShell.Run “Cscript %WinDir%System32SCregEdit.wsf /AU 1″ & NewComputerName,7,TRUE 
  end if
  
  if ucase(updateselection)=ucase(L_Msg137_Text) or ucase(updateselection)=ucase(L_Msg138_Text) then
   oShell.Run “Net stop wuauserv”,7,TRUE 
   oShell.Run “Net start wuauserv”,7,TRUE 
 
   MsgBox L_Msg051_Text & Update_schedule & “.  ” & strSchedule, vbInformation, L_Msg052_Text
  end if 
 
 Case “6” ‘Install Security Patches
 
  ‘Install all patches
  oShell.Run WUA_Script,1,False

  on error resume next
  patching_status = Now()
  oShell.RegWrite “HKLMSoftwareMicrosoftHyperVServerQuickSettingsPatchDate”,patching_status
  on error goto 0
 
 Case “7”    ‘Enable/disable Remote Desktop

    WScript.Echo
    wscript.StdOut.Write L_Msg053_Text
    rd = Wscript.StdIn.ReadLine

    if ucase(rd)=ucase(L_Msg129_Text) then ‘ Enable
     do
    wscript.echo
    wscript.echo L_Msg054_Text
    wscript.echo
    wscript.echo L_Msg055_Text
    wscript.echo
    wscript.StdOut.Write L_Msg056_Text
    rdsecuritylevel = Wscript.StdIn.ReadLine
   loop while not (rdsecuritylevel=”1″ or rdsecuritylevel=”2″)
   
      wscript.echo
   wscript.echo L_Msg057_Text
    
   ‘Enable Remote Desktop Admin mode
   result=oShell.Run(“Cscript %WinDir%System32Scregedit.wsf /ar 0 ” & NewComputerName,7,TRUE)
   oShell.Run “Cscript %WinDir%System32Scregedit.wsf /cs 1 ” & NewComputerName,7,TRUE  
 
   if result=0 then
    if rdsecuritylevel=2 then
     ‘Allow WinXP and Win 2003 clients
     oShell.Run “Cscript %WinDir%System32Scregedit.wsf /cs 0 ” & NewComputerName,7,TRUE
     msgbox L_Msg058_Text,Information,L_Msg059_Text    
    else
     msgbox L_Msg060_Text,Information,L_Msg059_Text    
    end if
   else
    msgbox L_Msg061_Text,vbCritical,L_Msg059_Text
   end if    
   
    end if
   
    if ucase(rd)=ucase(L_Msg130_Text) then
      wscript.echo
   wscript.echo L_Msg062_Text
      
   ‘Disable Remote Desktop mode
   result=oShell.Run(“Cscript %WinDir%System32Scregedit.wsf /ar 1 ” & NewComputerName,7,TRUE)
   oShell.Run “Cscript %WinDir%System32Scregedit.wsf /cs 1 ” & NewComputerName,7,TRUE
   
   if result=0 then
    msgbox L_Msg063_Text,vbInformation,L_Msg059_Text
   else
    msgbox L_Msg061_Text,vbCritical,L_Msg059_Text
   end if  
    end if

 Case “8” ‘Set Region and Language 
  oShell.Run “control intl.cpl”
  
 Case “9” ‘Set Date and Time
  oShell.Run “control timedate.cpl”      
   
 Case “10” ‘Logoff
  confirm = msgbox(L_Msg064_Text, vbYesNo+vbDefaultButton2,L_Msg065_Text)
  if confirm=vbYes then
   oShell.Run “logoff”,7,True
  end if  

 Case “11” ‘ Restart
  confirm = msgbox(L_Msg066_Text, vbYesNo+vbDefaultButton2,L_Msg030_Text)
  if confirm=vbYes then oShell.Run “shutdown /r /t 0″,1  
 
 Case “12” ‘ Shut Down
  confirm = msgbox(L_Msg067_Text, vbYesNo+vbDefaultButton2,L_Msg068_Text)
  if confirm=vbYes then oShell.Run “shutdown /s /t 0″,1 

 Case “13”  ‘Exit
  wscript.quit

 Case Else
 
  ‘msgbox “— Invalid input! —“

end Select

Loop until OptionSelection=”13″  ‘Loops back to main menu unless exiting

wscript.quit

sub CheckRemoteDesktop()
 ‘ True if Remote Desktop enabled
 Dim Sh, sKey, sValueName, sValue, nValue
 Set Sh = CreateObject(“WScript.Shell”)
 sKey = “HKLMSYSTEMCurrentControlSetControlTerminal Server”
 sValueName = “fDenyTSConnections”
 sValue = Sh.RegRead(SKey & sValueName)
 
 if sValue=0 then
  nValue= Sh.RegRead(sKey & “WinStationsRDP-TcpUserAuthentication”)
 if nValue = 0 then
  TS_status= L_Msg069_Text
 else
  TS_status= L_Msg070_Text
 end if
 else
  TS_status= L_Msg071_Text
 end if
 
End sub

Function LegalNicSelected(pickedNIC)
 LegalNicSelected=False
 For Each nic in nics
  if pickedNIC=CStr(nic.Index) then
   LegalNicSelected=True
  end if
 Next
end Function

Sub ManagementNICsettings()

 Set nics = objWMIService.ExecQuery(“SELECT * FROM Win32_NetworkAdapterConfiguration where IPenabled=TRUE”)
 Set objNetAdapter = GetObject(“winmgmts:Win32_NetworkAdapterConfiguration=” & MgmtNIC)  
  
 wscript.echo
 wscript.echo L_Msg072_Text
 wscript.echo L_Msg073_Text
 wscript.echo L_Msg072_Text
 wscript.echo
 wscript.echo
 wscript.echo L_Msg074_Text
 wscript.echo 
 wscript.echo L_Msg075_Text
        
 For Each nic in nics   
  if nic.IPenabled then
   DisplayIP = nic.IPAddress(0)
  else
   DisplayIP=L_Msg002_Text
  end if
  wscript.echo
  
  ‘Adjust spacing for non EN-US
  if instr(L_Msg075_Text,”Index#”) then  
   wscript.StdOut.Write ”  ” & nic.Index & VBTab & DisplayIP & VBTab & left(nic.Description,54) 
  else
   wscript.StdOut.Write ”  ” & nic.Index & VBTab & VBTab & DisplayIP & VBTab & left(nic.Description,47)
  end if
 Next
 
 wscript.Echo
 do
  wscript.Echo
  wscript.StdOut.Write L_Msg076_Text
  SelectedNIC = Wscript.StdIn.ReadLine
 loop until LegalNicSelected(SelectedNIC) or SelectedNIC = “”
 
   
 if SelectedNIC=”” then
   ‘Do nothing, Cancel was selected, return to main menu
 else
  ‘Set the MgmtNIC to a legal value  
  MgmtNIC=SelectedNIC    
   
   do
    wscript.echo
   wscript.echo L_Msg072_Text
   wscript.echo L_Msg077_Text
   wscript.echo L_Msg072_Text
   wscript.echo
   Set nics = objWMIService.ExecQuery(“SELECT * FROM Win32_NetworkAdapterConfiguration where IPenabled=TRUE”)  
   Set objNetAdapter = GetObject(“winmgmts:Win32_NetworkAdapterConfiguration=” & MgmtNIC)
   
   ‘Display NIC info (IP, DHCP, DNS)   
   For Each nic in nics
     if nic.index=cint(MgmtNIC) then  
    if nic.IPenabled then
     DisplayIP = nic.IPAddres

Comments (0)