Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-53003

Windows: network configuration Powershell script sometimes exits with code 1 instead of setting IP address

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • rhel-9.5
    • virt-v2v
    • No
    • Important
    • rhel-sst-virtualization
    • ssg_virtualization
    • 8
    • False
    • Hide

      None

      Show
      None
    • None
    • Migration Toolkit for Virtualization
    • None
    • None
    • None
    • None

      (https://access.redhat.com/support/cases/#/case/03881757/)

      Virt-v2v installs a Powershell script to set up the network at first boot. For unclear reasons, sometimes this script fails, exits with code 1, and does not set up the network. There are no other error messages visible.

      We talked through an example with the customer, and found that if the same script is run manually after boot, then it works fine.

      The script below is generated for the virt-v2v command line option --mac 12:12:12:34:34:34:ip:192.168.0.10,192.168.0.1,24,8.8.8.8

      # Uncomment this line for lots of debug output.
      # Set-PSDebug -Trace 1
      
      # Wait for the netkvm (virtio-net) driver to become active.
      $adapters = @()
      While (-Not $adapters) {
          Start-Sleep -Seconds 5
          $adapters = Get-NetAdapter -Physical | Where DriverFileName -eq "netkvm.sys"
          Write-Host "adapters = '$adapters'"
      }
      
      $mac_address = '12-12-12-34-34-34'
      $ifindex = (Get-NetAdapter -Physical | Where MacAddress -eq $mac_address).ifIndex
      if ($ifindex) {
          Write-Host "setting IP address of adapter at $ifindex"
          New-NetIPAddress -InterfaceIndex $ifindex -IPAddress '192.168.0.10' -DefaultGateway '192.168.0.1' -PrefixLength 24
          Set-DnsClientServerAddress -InterfaceIndex $ifindex -ServerAddresses ('8.8.8.8')
      }
      

              rhn-eng-rjones Richard Jones
              rhn-eng-rjones Richard Jones
              Arik Hadas, Liran Rotenberg, Ming Xie, Yan Vugenfirer
              virt-maint virt-maint
              Ming Xie Ming Xie
              Votes:
              0 Vote for this issue
              Watchers:
              14 Start watching this issue

                Created:
                Updated: