none
Changing IP Address to join a domain RRS feed

  • Question

  • I've set up HyperV R2 while connected to a cable internet access that assigned an IP address from DHCP. I need to join it to a domain with a static IP address. What is the best way to change the IP address to one that has been set up in the DNS server so I can join the HyperV server to the domain? Thank you.
    Dan Slaby
    Sunday, February 27, 2011 10:01 AM

Answers

  • I found this powershell script written by Andy Schneider that I was looking for on http://poshcode.org/531 :

    function Set-IPAddress {
      param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
       [string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
       [string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
       [string]$gateway = $(read-host "Enter the current name of the NIC you want to rename"),
       [string]$dns1 = $(read-host "Enter the first DNS Server (ie 10.2.0.28)"),
       [string]$dns2,
       [string]$registerDns = "TRUE"
       )
      $dns = $dns1
      if($dns2){$dns ="$dns1,$dns2"}
      $index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq $networkinterface}).InterfaceIndex
      $NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index}
      $NetInterface.EnableStatic($ip, $subnetmask)
      $NetInterface.SetGateways($gateway)
      $NetInterface.SetDNSServerSearchOrder($dns)
      $NetInterface.SetDynamicDNSRegistration($registerDns)


    Dan Slaby
    • Marked as answer by dslaby Tuesday, March 1, 2011 3:15 AM
    Tuesday, March 1, 2011 3:15 AM

All replies

  • There's no real difference in how you change it when Hyper-V is installed.

    Monday, February 28, 2011 6:11 PM
  • I found this powershell script written by Andy Schneider that I was looking for on http://poshcode.org/531 :

    function Set-IPAddress {
      param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
       [string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
       [string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
       [string]$gateway = $(read-host "Enter the current name of the NIC you want to rename"),
       [string]$dns1 = $(read-host "Enter the first DNS Server (ie 10.2.0.28)"),
       [string]$dns2,
       [string]$registerDns = "TRUE"
       )
      $dns = $dns1
      if($dns2){$dns ="$dns1,$dns2"}
      $index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq $networkinterface}).InterfaceIndex
      $NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index}
      $NetInterface.EnableStatic($ip, $subnetmask)
      $NetInterface.SetGateways($gateway)
      $NetInterface.SetDNSServerSearchOrder($dns)
      $NetInterface.SetDynamicDNSRegistration($registerDns)


    Dan Slaby
    • Marked as answer by dslaby Tuesday, March 1, 2011 3:15 AM
    Tuesday, March 1, 2011 3:15 AM